Error on renaming database in SQL Server 2008 R2
Solution 1:
You could try setting the database to single user mode.
https://stackoverflow.com/a/11624/2408095
use master
ALTER DATABASE BOSEVIKRAM SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE BOSEVIKRAM MODIFY NAME = [BOSEVIKRAM_Deleted]
ALTER DATABASE BOSEVIKRAM_Deleted SET MULTI_USER
Solution 2:
-
Set the database to single mode:
ALTER DATABASE dbName SET SINGLE_USER WITH ROLLBACK IMMEDIATE
-
Try to rename the database:
ALTER DATABASE dbName MODIFY NAME = NewName
-
Set the database to Multiuser mode:
ALTER DATABASE NewName SET MULTI_USER WITH ROLLBACK IMMEDIATE
Solution 3:
In SQL Server Management Studio (SSMS):
You can also right click your database in the Object Explorer and go to Properties. From there, go to Options. Scroll all the way down and set Restrict Access to SINGLE_USER. Change your database name, then go back in and set it back to MULTI_USER.
Solution 4:
Try to close all connections to your database first:
use master
ALTER DATABASE BOSEVIKRAM SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE BOSEVIKRAM MODIFY NAME = [BOSEVIKRAM_Deleted]
ALTER DATABASE BOSEVIKRAM_Deleted SET MULTI_USER
Taken from here