Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change database from Single user mode to multi user

I have a Database,Which is in Single user mode ,If i want to access a tables in the database i will be changing in the properties from single to multiuser.How can i make the Database multi user permenantly?.

like image 478
SqlLearner Avatar asked Jul 30 '14 19:07

SqlLearner


People also ask

How do I change database from single-user mode?

Right-click the database to change, and then select Properties. In the Database Properties dialog box, select the Options page. From the Restrict Access option, select Single. If other users are connected to the database, an Open Connections message will appear.

Can we convert single-user to multi-user?

You can convert a single-user model to a multi-user model and open it in the multi-user mode. On the File menu, click Sharing > Convert to a multi-user model. Enter the multi-user server name or select the name from the list in the Convert to multi-user model dialog box. Click Convert.


2 Answers

ALTER DATABASE [MyDB] SET MULTI_USER

If it throws an error like user is already connected to it, select 'master' db in the dropdown and try it that way.

If that doesn't do it, use sp_who to find what spid is accessing the DB and kill it.

like image 97
Kris Gruttemeyer Avatar answered Oct 01 '22 09:10

Kris Gruttemeyer


If you want to do it in SSMS object explorer.

Right click on your database. Go to properties > options. Scroll to the bottom and find "Restrict Access" and change it to multi_user. Click ok.

Just an alternative to query window. Both do the same the same.

like image 45
SQLChao Avatar answered Oct 01 '22 10:10

SQLChao