DevPinoy.org
A Filipino Developers Community
ATTENTION:Take our Code Challenge for the month of October 2008 and win some great prize! Learn more about it here!

dropping all users before restoring a database

during development, i always make use of backup-restore of test data and restoring a database requires that there is no other active connection to it.  i have these three ways to deal with it.

1.  use sp_who2 to determine the spid (what is spid again?) of connections to the database to be restored then kick every one of them.  i wonder why they always use spid 51 onwards in my scenario.

2.  use a script to do #1 which just supplies the database name to be restored (found this through usenet, i'll post the script tomorrow), I have this sp in the master database.

3.  ALTER DATABASE <dbname> SET SINGLE_USER ROLLBACK IMMEDIATE, restore database, then reset it to MULTI_USER. 


Posted Jan 11 2006, 03:44 PM by jokiz
Filed under: ,

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Enter the numbers above:

Copyright DevPinoy 2005-2008
Powered by Community Server (Commercial Edition), by Telligent Systems