Search This Blog

Rename failed for Database 'Testing_new'.

Rename failed for Database 'Testing_new'. 


Issue -Rename failed for Database 'Testing_new'
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The database could not be exclusively locked to perform the operation. (Microsoft SQL Server, Error: 5030)
Issue Description-While Renaming the Database in SQL using GUI get the above Issue

Solution-
To fix the above Issue
-Right click Database
-Properties
-Options
-Restrict Access
-Set to Single User
click ok

Once Done Rename the database 
by Right click
Rename
change the name to new Name-Testing_New
Once done 

Follow the same above process
-Right click Database
-Properties
-Options
-Restrict Access
-Set it back to Multi User
click ok

NOTE: we can also rename a database by  Running SP_RenameDB system Stored Proc.

--first parameter old db name second parameter new db name
exec SP_renamedb 'TestingNew' ,'Testing_New' 

No comments:

Post a Comment