Users: 15,000+ | Page Views: 50,000+ | PPS: 2.5
TechDevOps.com
Explore Tools
{Experts in Microsoft SQL Server Operations, Performance, HA/DR, Data Migrations & Cloud Computing}



Azure SQL Database Geo-Replication - Initiate a Failover using T-SQL
by BF (Senior MSSQL Operations - Enterprise, Cloud, Strategy)
2016-10-03









T-SQL:


Step 1: Connect to the Secondary Geo-Replicated Node using SQL Server Management Studio


Step 2: Open a New Query to the Master Database


Step 3: Execute ALTER DATABASE FAILOVER;




Helper T-SQL:


#1.On your Primary Node User Database:


select * from [sys].[dm_geo_replication_link_status]





sys.dm_geo_replication_link_status (Azure SQL Database)

Contains a row for each replication link between primary and secondary databases in a geo-replication partnership. This includes both primary and secondary databases. If more than one continuous replication link exists for a given primary database, this table contains a row for each of the relationships. The view is created in all databases, including the logical master. However, querying this view in the logical master returns an empty set.


#2. On your Primary Node Master Database:


select * from [sys].[dm_operation_status]





sys.dm_operation_status (Azure SQL Database)

Returns information about operations performed on databases in a Azure SQL Database server.