Rename SQL database

When you want to rename a database in SQL Server Mangement Studio you might run into an error. Running the query below should rename the database.

use master
ALTER DATABASE [current name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE    
ALTER DATABASE [current name] MODIFY NAME = [new name]
ALTER DATABASE [new name] SET MULTI_USER

Read more