I had to restore a database, but some of the users were still connected, and had left for the day. Previously, I had set the database to single user, now I do not see that option.
So, I made a change at instance level, setting Properties/Connections/Maximum number of concurrent users to 1, disconnecting all other users from the server.
I restarted the SQL Server service, but now I am unable to access the database at all. The database is up and running, but I can't open a query window or right click on Properties to revert the change.
How can I fix this?
Best Answer
First thing, never set Max Number of Concurrent Connections on the server properties page to 1. This option can even prevent administrators logging in, but in any case the Dedicated Administrator Connection can still be used.
Sometimes, after setting Max Number of Concurrent Connections to 1, on login you may face the following error message:
To fix this: In the login window, click on the Options button and in the default database item, select a database like tempdb and then press login.
If the database is in Single_User mode
Using T-SQL:
Using SSMS:
If the database is in Single_User mode, and you want to change it to Multi_User, but can't access it as someone else already have the connection, then:
If you have
ALTER ANY CONNECTION
rights (part of sysadmin and processadmin fixed server roles), runSP_WHO
orSP_WHO2
, find the process using the target database and execute:then execute above T-SQL to bring your database back to multi_user.
Or, you can detach and then attach your database and execute the T-SQL above to bring it to multi_user. This is not recommended on production servers.