Created
September 2, 2018 20:33
-
-
Save LetsGoRafting/567b2b34fc3a302cd8139736c3f99c1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF SERVERPROPERTY ('IsHadrEnabled') = 1 | |
BEGIN | |
SELECT | |
AGC.name -- Availability Group | |
, RCS.replica_server_name -- SQL cluster node name | |
, ARS.role_desc -- Replica Role | |
, AGL.dns_name -- Listener Name | |
FROM | |
sys.availability_groups_cluster AS AGC | |
INNER JOIN sys.dm_hadr_availability_replica_cluster_states AS RCS | |
ON | |
RCS.group_id = AGC.group_id | |
INNER JOIN sys.dm_hadr_availability_replica_states AS ARS | |
ON | |
ARS.replica_id = RCS.replica_id | |
INNER JOIN sys.availability_group_listeners AS AGL | |
ON | |
AGL.group_id = ARS.group_id | |
WHERE | |
ARS.role_desc = 'PRIMARY' | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment