December 15, 2010 at 10:05 am
Rather than looping through sys.sysprocesses and kill all SPID's, I remember that there was some ALTER DATABASE command that closes all existing connections ?
December 15, 2010 at 10:24 am
ALTER DATABASE DBNAMESET SINGLE_USER WITH ROLLBACK IMMEDIATE
The database will be in single user mode after this has run.
Gethyn Elliswww.gethynellis.com
December 15, 2010 at 11:23 am
Thanks Gethyn
This is exacltly what I needed. Also, should I set it to multi user after restore ?
December 16, 2010 at 2:31 pm
If the database was not backed up while in single user mode, then it will not be restored in that condition. So, no - you won't need to set it back.
You could also use the following:
ALTER DATABASE {your database} SET OFFLINE WITH ROLLBACK IMMEDIATE;
Then perform your restore. This will prevent any other processes from taking the single user connection and blocking your restore.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply