database stuck in single user and no spid

  • 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.

  • 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

  • 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

  • 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.

  • i hope you can also use "sp_dboptions '<DBName>' 'multiuser' 'true'"

  • 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

  • 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