Azure / SQL Server / Rename an Azure SQL database

We had one customer who was moving his Azure SQL Database from Elastic Pool to Standalone Database. At the same time, he wanted to change database name as well. Azure database was part of an existing failover group (two elastic pools) and geo-replicated to the new future Azure SQL Server.

Changing the database name is not allowed if the database is part of the replication


If the database is not part of replication we can use two different approaches to rename it, using:

  • SQL Server Management Studio
  • Transact-SQL

Note: This refers just to users databases


USING SQL Server Management Studio

Connect to your Azure SQL Server using SSMS


You can use your server admin account and connect to default DB (master)


Just one click on the database name and you will be able to type the new database name


Type new database name and confirm the change


USING Transact-SQL

Connect to your Azure SQL Server using SSMS and server admin credentials, connect to the default (master) DB.

Open new query window and run following query


Note: Never connect directly to the database you want to change the name.


Otherwise, you can have a problem with your current session/connection after you change DB name and end up with the following error




Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *