[AlwaysOn2017] AlwaysOn的DMV和DMF - Sys.fn_hadr_distributed_ag_replica

24、 Sys.fn_hadr_distributed_ag_replica

用于将映射到本地可用性组中的数据库的分布式的可用性组中的数据库。

语法

Sys.fn_hadr_distributed_ag_database_replica(lag_Id, database_id)

参数

lag_Id

是分布式的可用性组的标识符。 lag_Id 是类型 uniqueidentifier

database_id

是分布式的可用性组中的标识符。 database_id 是类型 uniqueidentifier

返回的表

返回以下信息。

列名

数据类型

描述

group_database_id

uniqueidentifier

本地可用性组中的数据库的ID。

示例

下面的示例将分布式的可用性组中的数据库ID中传递。它返回具有与本地可用性组关联的数据库ID的表。

DECLARE @lagId uniqueidentifier = '4A03D1A8-4AE6-B153-E7E9-ED22A546008D'

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