Single user mode issue

Sometimes ,mostly because you did something , your DB is stuck in a single user mode and you cannot connect to it anymore.

Below steps can help if you don’t know which user is connected to the DB.

SELECT request_session_id FROM sys.dm_tran_locks
WHERE resource_database_id = DB_ID(‘YourDatabase’)

It will return the process connected to the DB with PID
Then kill all process that use your database with following query:

KILL spid

Then run following query to change to multi user mode.

USE Master
ALTER DATABASE YourDatabase SET MULTI_USER

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s