Verify global primary replica in a SQL Server Distributed availability Group
0
votes
1
answer
57
views
I'm trying to write a script for a SQL Agent job. As part of this, the first thing I need the job to do is to test for the global primary replica, for which I have come up with the following code:
select * from sys.dm_hadr_availability_group_states
where primary_replica like '%_AG1' and primary_recovery_health = 1
All our DAG global primary replicas are always xx_AG1
Does anyone see any situation where the above code will not uniquely select my healthy global primary please?
thank you
Asked by PTL_SQL
(427 rep)
May 15, 2025, 03:04 PM
Last activity: May 19, 2025, 10:27 PM
Last activity: May 19, 2025, 10:27 PM