In AWS RDS based SQL Server, you cannot rename a database from SQL Server management studio. You will get an error about permissions. You need to use rdsadmin command to accomplish that.
If you get error:
Msg 5030, Level 16, State 2, Line 1
The database could not be exclusively locked to perform the operation.
Then you need to set the database first to single user, rename it and then revert back to multi user. Use following steps to rename SQL Server database in AWS RDS:
ALTER DATABASE OldDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
exec rdsadmin.dbo.rds_modify_db_name 'OldDB','NewDB'
ALTER DATABASE NewDB SET MULTI_USER
Hope that helps.
Post a Comment