How to change database from Single user mode to multi user
Asked Answered
B

3

7

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?.

Baiss answered 30/7, 2014 at 19:19 Comment(0)
R
13

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.

Rianna answered 30/7, 2014 at 19:21 Comment(0)
R
2

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.

Rene answered 30/7, 2014 at 19:47 Comment(2)
But every day morning it is going back to single User mode.Is there any way i can do it permenantly.Baiss
@Baiss Is the database being restored daily? Maybe there is a job that alters the database? Something is changing it back to single. I've had an instance where database properties appeared to change on their own and it ended up being a 3rd party script.Rene
W
0

Other solution.

I have the same error as you, I have tried all the ways but it doesn't work. Manually below I have restored to the original state of the database.

Step 1: Stop Sql Server Services
Step 2: Cut Data and Log file to other folder.
Step 3: Start Sql Server Services again.
Step 4: In SQL Studio Management -> Delete error database.
Step 5: Stop Sql Server Services and Copy Data to old folder.
Step 6: Attach again and auto change from single user to multi user

This solution test on Sql Server 2017 by me.

Wonderstricken answered 21/9, 2021 at 2:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.