question

rsampson avatar image
rsampson asked

Availability group query, who's my primary

From any server in Availability group (only have one), can I find out what server is primary ? Thanks
availability-groupsprimary
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

JohnM avatar image
JohnM answered
You should be able to use the DMV sys.dm_hadr_availability_group_states. It should report which server is currently hosting the primary replica. Reference: https://msdn.microsoft.com/en-us/library/ff878491.aspx Hope that helps!
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

rsampson avatar image
rsampson answered
In 2012, my query from sys.dm_hadr_availability_group_states , primary_replica is NULL... I guess they decided to fill that in later ? Thanks
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

From the link I provided, "NULL = Not the primary replica or unable to communicate with the WSFC failover cluster". I would assume that if the WSFC cluster is functional, then NULL simply says that the current instance you are running the query isn't the primary. I quite possible read the description incorrectly.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.