When trying to rename manually it throws this error:
So after some research over internet I have found the reason and solution for this error. The reason of this error is that multiple connection is established with database that is why it cannot let me rename the database so in order to fix the issue I have to kill all the connections to the database. I use the ALTER DATABASE command to resolve the issue.
- Set the database to single mode:
- ALTER DATABASE YourDatabaseName
- SET SINGLE_USER WITH ROLLBACK IMMEDIATE
- ALTER DATABASE YourCurrentDatabaseName MODIFY NAME = YourChangeDatabaseName
- ALTER DATABASE YourChangeDatabaseName
- SET MULTI_USER WITH ROLLBACK IMMEDIATE