MOD/REMAINDER – Learn more on the SQLServerCentral forums. Good morning-Anyone have any thoughts on how to enable a MOD function? Basically what I need is a formula that would look at a fraction. Besides the MOD function, some database systems provide a built-in modulo operator% such as Microsoft SQL, MySQL, and PostgresQL that is equivalent to the MOD function. SQL MOD examples. The following statement divides the number 33 by 5 that results in 6 as the integer portion of the result and 4 as the remainder.
Related Articles
- 1 Most Successful Start Up Business Areas
- 2 Rebuild a Print Spooler
- 3 Start XServer on Bootup in Linux
- 4 Remove Registry Entries for Msconfig Start up Programs
Organizations can use SQL Server to reduce downtime, manage and secure databases, and discover patterns in mission-critical information to improve business intelligence. To rebuild a corrupted master database, you must run an instance of SQL Server in single-user mode, which prevents multiple clients from connecting to the server at the same time. You can reconfigure the startup options associated with SQL Server to limit the number of connections to the server.
1.Click 'Start | All Programs | Microsoft SQL Server 2012 | Configuration Tools.'
2.Click 'SQL Server Configuration Manager.' Select 'SQL Server Services' from the left pane and then right-click the server.
3.Choose 'Properties' from the context menu. Click 'Startup Parameters.' Select the the field next to Specify a Startup Parameter and then enter '-m' -- without the quotes.
4.Click 'Add,' then 'OK.' Restart SQL Server to run the instance in single-user mode.
Tip
- You should restart SQL Server Agent before launching the instance of SQL Server in single-user mode. Click 'View,' then 'Object Explorer.' Right-click 'SQL Server Agent' and then click 'Stop.'
References (1)
About the Author
Ruri Ranbe has been working as a writer since 2008. She received an A.A. in English literature from Valencia College and is completing a B.S. in computer science at the University of Central Florida. Ranbe also has more than six years of professional information-technology experience, specializing in computer architecture, operating systems, networking, server administration, virtualization and Web design.
Photo Credits
- database on paper image by .shock from Fotolia.com
Choose Citation Style
![Sql Sql](/uploads/1/2/3/7/123758626/535962506.jpg)
Ranbe, Ruri. 'How to Start SQL in Single-User Mode.' Small Business - Chron.com, http://smallbusiness.chron.com/start-sql-singleuser-mode-56012.html. Accessed 15 June 2019.
Ranbe, Ruri. (n.d.). How to Start SQL in Single-User Mode. Small Business - Chron.com. Retrieved from http://smallbusiness.chron.com/start-sql-singleuser-mode-56012.html
Ranbe, Ruri. 'How to Start SQL in Single-User Mode' accessed June 15, 2019. http://smallbusiness.chron.com/start-sql-singleuser-mode-56012.html
Note: Depending on which text editor you're pasting into, you might have to add the italics to the site name.
What is single-user mode?
There are certain situations when user may have to start a SQL Server instance in single-user mode. For example, you might need to restore your master database from a backup in the event of a failure or damage, detach the database and kill all the connections. Both actions require starting an instance of SQL Server in single-user maintenance mode.
When a database is started in single-user mode, the following events occur:
- Any current connections to the database are dropped without warning
- Only one user can connect to the database
- The CHECKPOINT process is not started
I’m going to walk you through the process of putting your SQL Server database into single-user mode. This can be either done via SQL Server Configuration Manager by setting the startup parameters or through the Command Prompt.
Method 1: Start SQL Server in single-user mode through SQL Server Configuration Manager
Run SQL Server Configuration Manager. Choose SQL Server Services from the left panel and then right-click on desired SQL Server service that needs to run in single-user mode. Select Properties from the drop-down menu.
In SQL Server 2014 or 2012, click Startup Parameters tab. Type -m in the Specify a startup parameter box and then click Add.
If you’ve installed SQL Server 2008, 2005 or an earlier version, click Advanced tab. Append the ;-m to the end of the Startup Parameters box.
Click Apply to save your changes. Restart your SQL Server instance and it should then run in single-user mode.
Method 2: Start SQL Server in single-user mode through Command Prompt
First of all, you need to figure out the name of your SQL Server instance. Press Windows key + R to bring up the Run box. Type services.msc and press Enter to open the Services window.
Find your desired SQL Server service in the list, double click it. This will open the Properties dialog box for that service. Copy the service name listed there. In my example, the service name is MSSQL$SQLEXPRESS.
Open up a Command Prompt with administrative privileges and run the following command to stop the SQL Server service.
net stop service_name
The next step is to start the service in single-user mode. This is done by specifying /m parameter with
net start
command.How to know if a running SQL Server instance is in single-user mode
When your SQL Server instance is started in single-user mode, it prevents multiple clients from connecting to the server at the same time. For example, if you’ve already connected to your DB with the SA account, and then try to login again through SQL Server Management Studio (SSMS), you’ll get the following error message:
Login failed for user”. Reason: Server is in single user mode. Only one administrator can connect at this time. (Microsoft SQL Server, Error: 18461)
To fix this issue, you need to remove -m from the startup parameters and restart your SQL Server instance, which will bring the database back to multi-user mode.