Search code examples
azure-sql-managed-instancegeo-replication

Rename a database on Azure SQL Managed Instance that is part of geo-replication


I have an Azure SQL Managed Instance that is set up with geo-replication. I have a database on this MI that I want to swap out with another database by renaming them:

ALTER DATABASE mydb MODIFY NAME = mydb_old; 
ALTER DATABASE mydb_new MODIFY NAME = mydb;

When I run this, I get an error error:

The operation cannot be performed since the database 'mydb' is in a replication relationship.

What do I need to do to allow me to rename the databases?


Solution

  • Yes, database rename does not work if Geo-replication is enabled. The same behavior is in Azure SQL Database - Singleton, so generally RENAME and Geo-replication don't work together in Azure SQL.

    Could you file this in SQL DB feedback forum highlighting that rename should be supported if Geo-replication is setup on database/instance so people could vote for this: https://feedback.azure.com/forums/217321-sql-database