| title | sp_wait_for_database_copy_sync | ||
|---|---|---|---|
| titleSuffix | Azure SQL Database | ||
| ms.date | 03/03/2017 | ||
| ms.service | sql-database | ||
| ms.reviewer | |||
| ms.topic | language-reference | ||
| f1_keywords |
|
||
| dev_langs |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | 7068da7f-cb74-47f2-b064-eb076a0d3885 | ||
| author | stevestein | ||
| ms.author | sstein | ||
| monikerRange | =azuresqldb-current||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current | ||
| ms.custom | seo-dt-2019 |
[!INCLUDEtsql-appliesto-xxxxxx-asdb-xxxx-xxx-md]
This procedure is scoped to an [!INCLUDEssGeoDR] relationship between a primary and secondary. Calling the 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 sp_wait_for_database_copy_sync on only the primary database.
| Applies to: [!INCLUDEssSDSfull]. |
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.
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 is lost. sp_wait_for_database_copy_sync will 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
sys.dm_continuous_copy_status (Azure SQL Database)
Geo-Replication Dynamic Management Views (DMVs) and Functions (Azure SQL Database)
sys.dm_geo_replication_link_status