SQL Server - Database Stuck In Single User Mode

ben himself's picture

If you put your database into SINGLE USER mode but someone connects before you, then they lock you out!  Not good!  How do you regain control?  You need to find the SPID of the connected user and kill the SPID (not the user).

http://serverfault.com/questions/285232/sql2005-stuck-in-single-mode-user
    
    
*/

-- Find the SPID
SELECT * FROM MASTER..SysProcesses WHERE dbid = DB_ID('DB_NAME_HERE')

-- Kill the SPID
-- KILL ENTER_THE_SPID_NUMBER

Tags: 

Categories: