Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server 2016 (13.x) and later versions
Used to map a database in a distributed availability group to the database in the local availability group.
Transact-SQL syntax conventions
sys.fn_hadr_distributed_ag_database_replica( lag_Id, database_id )
'lag_Id'
Is the identifier of the distributed availability group. lag_Id is type uniqueidentifier.
'database_id'
Is the identifier of the database in a distributed availability group. database_id is type uniqueidentifier.
Returns the following information.
Column name | Data type | Description |
---|---|---|
group_database_id | uniqueidentifier | ID of the database in the local availability group. |
The following example passes in 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-4AE6-B153-E7E9-ED22A546008D'
DECLARE @databaseId uniqueidentifier = '3FFA882A-C4C3-5B9E-A203-8F44BD9659F7'
SELECT * FROM sys.fn_hadr_distributed_ag_database_replica(@lagId, @databaseId)
GO
Always On Availability Groups Functions (Transact-SQL)
Always On Availability Groups (SQL Server)
Distributed Availability Groups (Always On Availability Groups)
CREATE AVAILABILITY GROUP (Transact-SQL)
ALTER AVAILABILITY GROUP (Transact-SQL)
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today