Quantcast
Channel: Couldn't restore database and couldn't change Single user mode to Multi user mode - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by RLF for Couldn't restore database and couldn't change Single user mode to Multi user mode

$
0
0

Here is what I do to ensure that I get the ONE (1) connection for SINGLE_USER.

USE MyDB;  -- Use the database you want to make SINGLE_USERGOALTER DATABASE MyDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;GORESTORE DATABASE ----; /* Or whatever you need to do. */GOALTER DATABASE MyDB SET MULTI_USER;GO

The trick is to be in the database already when you switch to SINGLE_USER mode. This way, you are the SINGLE_USER and nobody else can get in until you return the database to MULTI_USER.

NOTE: If you exit the database while in SINGLE_USER mode someone else can take over the database. This can also cause you problems.


Viewing all articles
Browse latest Browse all 2

Trending Articles