Active Geo-Replication - sp_wait_for_database_copy_sync
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.
sp_wait_for_database_copy_sync [ @target_server = ] 'server_name' , [ @target_database = ] 'database_name'
[ @target_server = ] 'server_name'
The name of the 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 cannot be found to the specified server name or database.
Interlink connectivity has been lost, and
sys.sp_wait_for_database_copy_syncwill return after the connection timeout.
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.
All transactions committed before a sp_wait_for_database_copy_sync call are sent to the active secondary database.
The following example invokes sp_wait_for_database_copy_sync to ensure that all transactions are committed to the primary database, db0, get sent to its active secondary database on the target server ubfyu5ssyt.
USE db0; GO EXEC sys.sp_wait_for_database_copy_sync @target_server = N'ubfyu5ssyt1', @target_database = N'db0'; GO