When I was trying the rename the database manually the Microsoft SQL Server was throwing the below error:
The database could not be exclusively locked to perform the operation.
After doing some research on this. I found out that there were some connections with that database already exists.
To resolve this we need to close all the connections first and than rename the database.
Below is the query to do all of this for us.
use master
ALTER DATABASE OldDBName SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE OldDBName MODIFY NAME = [NewDBName]
ALTER DATABASE NewDBName SET MULTI_USER
here OldDBName is the name of your existing database and NewDBName is the name that you want to change.
More information on this can be found on the below link.
http://stackoverflow.com/questions/16685269/error-on-renaming-database-in-sql-server-2008-r2
Thanks
Muhammad Zahid.
The database could not be exclusively locked to perform the operation.
After doing some research on this. I found out that there were some connections with that database already exists.
To resolve this we need to close all the connections first and than rename the database.
Below is the query to do all of this for us.
use master
ALTER DATABASE OldDBName SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE OldDBName MODIFY NAME = [NewDBName]
ALTER DATABASE NewDBName SET MULTI_USER
here OldDBName is the name of your existing database and NewDBName is the name that you want to change.
More information on this can be found on the below link.
http://stackoverflow.com/questions/16685269/error-on-renaming-database-in-sql-server-2008-r2
Thanks
Muhammad Zahid.