Why do I need to set the database to single_user before renaming it?
ALTER DATABASE A SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE A MODIFY NAME = [B]
ALTER DATABASE B SET MULTI_USER
According to Microsoft documentation, I have to set the database to single_user and then rename it. Why is this? If it's just a question to make sure all connections are closed, wouldn't this work ?:
ALTER DATABASE A SET OFFLINE WITH ROLLBACK IMMEDIATE
+3
source to share
1 answer
To avoid problems while other users are querying the database. This way you make him a single user and only you can hit him.
Read more about this here: https://docs.microsoft.com/en-us/sql/relational-databases/databases/set-a-database-to-single-user-mode
+4
source to share