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