SQL SERVER – How to : “The database could not be exclusively locked to perform the operation”

If you are facing this error : “The database could not be exclusively locked to perform the operation. (Microsoft SQL Server, Error: 5030)” when you try to rename SQL server database you need to temporary switch from Multi User mode to single user mode, then rename the database and then set it back to Multi user mode.

Do it step by step.

ALTER DATABASE dbName
SET SINGLE_USER WITH ROLLBACK IMMEDIATE

ALTER DATABASE dbName MODIFY NAME = dbNewName

ALTER DATABASE dbNewName
SET MULTI_USER WITH ROLLBACK IMMEDIATE


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s