[AlwaysOn2017] DMV and DMF-Sys.fn_hadr_distributed_ag_replica of AlwaysOn
24 、 Sys.fn_hadr_distributed_ag_replica
A database in a distributed availability group used to map to a database in a local availability group.
Grammar
Sys.fn_hadr_distributed_ag_database_replica (lag_Id, database_id)
Parameters.
Lag_Id
Is the identifier of the distributed availability group. Lag_Id is the type uniqueidentifier.
Database_id
Is an identifier in a distributed availability group. Database_id is the type uniqueidentifier.
Returned table
Returns the following information.
Column name
Data type
Description
Group_database_id
Uniqueidentifier
The ID of the database in the local availability group.
Example
The following example is passed to the database ID in a distributed availability group. It returns a table with the database ID associated with the local availability group.
DECLARE @ lagId uniqueidentifier = '4A03D1A8-4AE6MurB153murE7E9MusED22A546008D'
DECLARE @ databaseId uniqueidentifier = '3FFA882A-C4C3-5B9E-A203-8F44BD9659F7
SELECT * FROM Sys.fn_hadr_distributed_ag_database_replica (@ lagId, @ databaseId)
GO
Select * from Sys. Availability_databases_cluster
Select column_id, c. Name col_name, t. Name col_type
, c. Max_length, c. Precision, c. Scale
From Sys. All_columns c left join Sys. Types t
On c. System_type_id = t. System_type_id and c. User_type_id = t. User_type_id
Where object_id = OBJECT_ID ('Sys.availability_databases_cluster')
Order by column_id