Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I need help with setting a database that was restored in SINGLE_USER mode to MULTI_USER. Every time I run

ALTER DATABASE BARDABARD

SET MULTI_USER;

GO

I get this error:

Changes to the state or options of database 'BARDABARD' cannot be made at this time.

The database is in single-user mode, and a user is currently connected to it.

It needs to be in the non-SINGLE_USER mode to set it to another mode, but I can’t set the database in any other mode while it is SINGLE_USER mode.

1 Answer

0 votes
by (40.7k points)

The above error message usually occurs only if there are other processes connected to the database. 

Use the below code to see which processes are connected:

exec sp_who

The above code will return the process and then you will be able to run.

Use below command to end the process:

kill [XXX]

Here [xxx] is the SPID (Server Process ID) for the processes that you are trying to kill.

Now, you can run the above statement.

Related questions

Browse Categories

...