Düzenle

Aracılığıyla paylaş


sp_wait_for_database_copy_sync (Active geo-replication)

Applies to: Azure SQL Database Azure SQL Managed Instance

This procedure is scoped to an Active Geo-Replication relationship between a primary and secondary. Calling the sys.sp_wait_for_database_copy_sync causes the application to wait until all committed transactions are replicated and acknowledged by the active secondary database. Run sys.sp_wait_for_database_copy_sync on only the primary database.

Syntax

sp_wait_for_database_copy_sync [ @target_server = ] 'server_name'
     , [ @target_database = ] 'database_name'

Arguments

[ @target_server = ] 'server_name'

The name of the Azure SQL Database server that hosts the active secondary database. server_name is sysname, with no default.

[ @target_database = ] 'database_name'

The name of the active secondary database. database_name is sysname, with no default.

Return code values

Returns 0 for success or an error number for failure.

The most likely error conditions are as follows:

  • The server name or database name is missing.

  • The link can't be found to the specified server name or database.

  • Interlink connectivity has been lost, and sys.sp_wait_for_database_copy_sync will return after the connection timeout.

Permissions

Any user in the primary database can call this system stored procedure. The login must be a user in both the primary and active secondary databases.

Remarks

All transactions committed before a sp_wait_for_database_copy_sync call are sent to the active secondary database.

Examples

The following example invokes sp_wait_for_database_copy_sync to ensure that all transactions are committed to the primary database, AdventureWorks, get sent to its active secondary database on the target server serverSecondary.

USE AdventureWorks;
GO
EXEC sys.sp_wait_for_database_copy_sync @target_server = N'serverSecondary', @target_database = N'AdventureWorks';
GO