Get Out of SINGLE_USER Mode

If you find yourself stuck in SINGLE_USER mode in a SQL Server database, do the following:

1 - Find SPIDs connected to your database

1USE master
2GO
3EXEC sp_who

Note any SPIDs connected to your database, and then…

2 - Kill connections

1KILL [spid] -- do this for each spid returned by exec sp_who

3 - Set back to MULTI_USER

1USE Master
2ALTER DATABASE DatabaseName SET MULTI_USER

Plan B (If that doesn’t work)

If that doesn’t work, the following query can be used to find the connection(s):

1SELECT
2	request_session_id
3FROM
4	sys.dm_tran_locks
5WHERE
6	resource_database_id = DB_ID('DatabaseName')

Note any spid’s that are returned, and then run

1KILL [spid] -- do this for each spid returned by the previous query
2
3
4USE Master
5ALTER DATABASE YourDatabase SET MULTI_USER

Source: Stack Overflow