September 17, 2012 at 4:29 am
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?:w00t: As i would like to overwrite this database with the live database.
September 17, 2012 at 5:01 am
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
*******:cool:
Sudhakar
September 17, 2012 at 5:06 am
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
September 18, 2012 at 3:42 am
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.
September 18, 2012 at 10:16 am
i hope you can also use "sp_dboptions '<DBName>' 'multiuser' 'true'"
September 19, 2012 at 1:12 am
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
September 21, 2012 at 11:07 am
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.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply