Collections:
Database in Use When Renaming a Database in SQL Server
Why I am getting this error when renaming a database in SQL Server?
✍: FYIcenter.com
If you are trying to rename a database that is in use, you will get an error message like this: "The database could not be exclusively locked to perform the operation."
Before renaming a database, you must stop all client sessions using this database. Otherwise, you will get an error as shown in this tutorial example:
1. Launch one instance of SQL Server Management Studio and run:
USE FyiCenterComData GO
2. Keep the first instance running and launch another instance of SQL Server Management Studio:
ALTER DATABASE FyiCenterComData MODIFY NAME = FyiCenterData GO Msg 5030, Level 16, State 2, Server LOCALHOST\SQLEXPRESS The database could not be exclusively locked to perform the operation.
Obviously, the first instance is blocking the "ALTER DATABASE" statement.
⇒ ONLINE/OFFLINE - Database States in SQL Server
⇐ Renaming Database Names in SQL Server
2016-11-20, 1741🔥, 0💬
Popular Posts:
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...
How To Use DATEADD() Function in SQL Server Transact-SQL? DATEADD() is a very useful function for ma...
Where to find Oracle database server tutorials? Here is a collection of tutorials, tips and FAQs for...
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...
How To Fix the INSERT Command Denied Error in MySQL? The reason for getting the "1142: INSERT comman...