This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing one T-SQL script to monitor the status and health of AlwaysOn Availability Groups of SQL Server.
You can run this script in any primary server and get the information like Group name, Replica server name, Role description, Synchronization state.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
DECLARE @DRName varchar(30) SET @DRName = @@SERVERNAME select n.group_name ,n.replica_server_name ,n.node_name,rs.role_desc ,db_name(drs.database_id) as database_name ,drs.synchronization_state_desc ,drs.synchronization_health_desc from sys.dm_hadr_availability_replica_cluster_nodes n join sys.dm_hadr_availability_replica_cluster_states cs on n.replica_server_name = cs.replica_server_name join sys.dm_hadr_availability_replica_states rs on rs.replica_id = cs.replica_id join sys.dm_hadr_database_replica_states drs on rs.replica_id=drs.replica_id where n.replica_server_name <> @DRName |
Leave a Reply