|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, November 08, 2012 5:56 AM
Points: 40,
Visits: 277
|
|
Hi i have a dev database that is stuck in single user mode when i try and access the database i can't a connection already in use. However when i use exec sp_who - no connections are displayed against the database.
How can i get out of this please? As i would like to overwrite this database with the live database.
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, September 21, 2012 2:54 AM
Points: 91,
Visits: 74
|
|
Try this and see if it fixes ur problem.
use Master Go select * from master.sys.sysprocesses where spid>50 -- don't want system sessions and dbid = DB_ID(name of database in question)
--Find the SPID which is making connection to your single_user mode DB and KIll it Kill 100 -- replace 100 with the SPID which you get from the above query
ALTER database 'your DB name' set MULTI_USER with ROLLBACK IMMEDIATE
******* Sudhakar
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, November 08, 2012 5:56 AM
Points: 40,
Visits: 277
|
|
Sudhakar Vallamsetty (9/17/2012) Try this and see if it fixes ur problem.
use Master Go select * from master.sys.sysprocesses where spid>50 -- don't want system sessions and dbid = DB_ID(name of database in question)
--Find the SPID which is making connection to your single_user mode DB and KIll it Kill 100 -- replace 100 with the SPID which you get from the above query
ALTER database 'your DB name' set MULTI_USER with ROLLBACK IMMEDIATE
Hi Sudhakar,
I already tried this and there are no open connections listed against the database
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 8:24 AM
Points: 1,272,
Visits: 4,309
|
|
| Are you using SQL Management Studio to issue these commands? It has an annoying tendency of opening multiple connections to the database, so you'd be better off using SQLCMD to test this out.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Today @ 6:27 AM
Points: 120,
Visits: 80
|
|
| i hope you can also use "sp_dboptions '<DBName>' 'multiuser' 'true'"
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, November 08, 2012 5:56 AM
Points: 40,
Visits: 277
|
|
in the end had to get someone to log into server with sys admin user and detach and then re-attach database.
Thanks for the tip about the management studio. Next time i will try sqlcmd
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 12:30 AM
Points: 1,788,
Visits: 3,330
|
|
You can also see who is holding a lock on the database by querying sys.dm_tran_locks.
Kill the session_id and change to multi user by executing ALTER DATABASE db SET MULTI_USER.
|
|
|
|