Friday, July 15, 2016

(Solved) Error: Changes to the state or options of database '' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.

Error:

Changes to the state or options of database '' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.

Solution:


  1. ALTER DATABASE [dbname] set multi_user
  2.  
  3. SELECT request_session_id FROM sys.dm_tran_locks
  4. WHERE resource_database_id = DB_ID('[dbname]')
  5.  
  6. KILL [session_id]

(Solved) Error: Exclusive access could not be obtained because the database is in use

Error:

Exclusive access could not be obtained because the database is in use

Solution:


  1. USE MASTER;
  2. ALTER DATABASE [dbname] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;