Thursday, July 3, 2014

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

Hi All,

While renaming sql server database if you get following error 
The database could not be exclusively locked to perform the operation. (Microsoft SQL Server, Error: 5030) that means your database is in multi-user mode.

To resolve this issue, you need to first set database single user mode 

ALTER DATABASE dbName
SET SINGLE_USER WITH ROLLBACK IMMEDIATE

Now, Rename the database using following command

ALTER DATABASE dbName MODIFY NAME = dbName_new

At the end, Set database mode to multi-user 

ALTER DATABASE dbName

SET MULTI_USER WITH ROLLBACK IMMEDIATE

Hope this will resolve your issue.

Thanks & Regards,
Sachin K.

No comments:

Post a Comment