Error on renaming database in SQL Server, when rename the database:
1 | ALTER DATABASE MY_DB MODIFY NAME = [MY_DB_bak] |
But it shows an error when executing:
1 | The database could not be exclusively locked to perform the operation. |
The solution is setting the database to single user mode.
1 | use master |