Answers for "database rename failed .. The database could not be exclusively locked to perform the operation."

SQL
0

database rename failed .. The database could not be exclusively locked to perform the operation.

//this happens because the database is in multi user mode
// so the solution is 
//First we will see how to set the database to single user mode,

ALTER DATABASE dbName
SET SINGLE_USER WITH ROLLBACK IMMEDIATE

Now we will try to rename the database

ALTER DATABASE dbName MODIFY NAME = dbNewName


Finally we will set the database to Multiuser mode


ALTER DATABASE dbName
SET MULTI_USER WITH ROLLBACK IMMEDIATE
Posted by: Guest on September-21-2021

Code answers related to "database rename failed .. The database could not be exclusively locked to perform the operation."

Code answers related to "SQL"

Browse Popular Code Answers by Language