Via transact SQL with this query:
SELECT ag.[name] as 'AG Name',
ag.Is_Distributed,
ar.replica_server_name as 'Replica Name'
FROM sys.availability_groups ag,
sys.availability_replicas ar
WHERE ag.group_id = ar.group_id;
I can find the avaibility groups (distributed or not) visible from SQL server.
If it is an AG member I can see the instance. When it is DAG I cannot see the instances…
From the primary, with a query, there is a way to get the primary instance of the secondary AG in the DAG?
Or to get the listener name of the secondary AG..
Best Answer
At least to my knowledge, you cannot get the list of servers that are participating in the Distributed Availability Group (DAG). This (set) of queries is what I use to look at my environment which uses DAG's extensively. It shows the DAG and lists the two groups that are participating it and then later shows the health information for the local availability group(s) that are on the server you are talking to. But this should be enough to get you started. But you have to connect to both listeners to see the status of all nodes.
Well, it doesn't give you the listener name directly, but if you parse the endpoint_url you can use that to connect.