Tuesday, June 28, 2011

Changing The SQL Database In Single User Mode And Back To The Multi-User Mode


It is often necessary to modify the database in single user mode, especially if you are the DBA. A simple example would be to change the sorting options, or settings TE. A single user only allows a user (typically the DBA) to access the database. Therefore, it is easy to make changes without worrying about the blind alleys, and any claim, DB, and also without affecting users.

It is very easy to change the database in single user mode, in fact, it's just a script. Use the following script to change the mode.

ALTER DATABASE < > SET SINGLE_USER no_wait

NO_WAIT clause to set the single-user mode, when you run the query. Replacing this is to use the system stored sp_dboption

EXEC sp_dboption < > 'SINGLE USER', False

However, you must set the database in multiuser mode for other users to use. Without it, it will not be available to others.

Here is a script to set the basis for multi-mode.

ALTER DATABASE < > GAME MULTI_USER no_wait

Or alternative

EXEC sp_dboption < 'SINGLE USER'>, False

I advise you to maintain caution while changing database in single user mode, because it would link users already connected to the database.

1 comment:

  1. sql recovery has necessary probabilities for solving out issues related to corrupted or lost mdf files. It restores .mdf after power failures, hacker attacks. The tool starts under all available MS Windows working with big mdf files too.

    ReplyDelete