How to: Validate Data at the Subscriber (Replication Transact-SQL Programming)
Replication enables you to programmatically validate that data at the Subscriber matches data at the Publisher using replication stored procedures, where the procedures used depend on the type of replication topology.
To validate data for all articles in a transactional publication
At the Publisher on the publication database, execute sp_publication_validation(Transact-SQL). Specify @publication and one of the following values for @rowcount_only:
- 1 - rowcount check only (the default)
- 2 - rowcount and binary checksum.
[!참고] When you execute sp_publication_validation(Transact-SQL), sp_article_validation(Transact-SQL) is executed for each article in the publication. To successfully execute sp_publication_validation(Transact-SQL), you must have SELECT permissions on all columns in the published base tables.
(Optional) Start the Distribution Agent for each subscription if it is not already running. For more information, see 방법: 끌어오기 구독 동기화(Replication Programming) and 방법: 밀어넣기 구독 동기화(Replication Programming).
Check the agent output for the result of the validation. For more information, see 복제된 데이터의 유효성 검사.
To validate data for a single article in a transactional publication
At the Publisher on the publication database, execute sp_article_validation(Transact-SQL). Specify @publication, the name of the article for @article, and one of the following values for @rowcount_only:
- 1 - Rowcount check only (the default)
- 2 - Rowcount and binary checksum.
[!참고] To successfully execute sp_article_validation(Transact-SQL), you must have SELECT permissions on all columns in the published base table.
(Optional) Start the Distribution Agent for each subscription if it is not already running. For more information, see 방법: 끌어오기 구독 동기화(Replication Programming) and 방법: 밀어넣기 구독 동기화(Replication Programming).
Check the agent output for the result of the validation. For more information, see 복제된 데이터의 유효성 검사.
To validate data for a single subscriber to a transactional publication
At the Publisher on the publication database, open an explicit transaction using BEGIN TRANSACTION(Transact-SQL).
At the Publisher on the publication database, execute sp_marksubscriptionvalidation(Transact-SQL). Specify the publication for @publication, the name of the Subscriber for @subscriber, and the name of the subscription database for @destination_db.
(Optional) Repeat step 2 for each subscription being validated.
At the Publisher on the publication database, execute sp_article_validation(Transact-SQL). Specify @publication, the name of the article for @article, and one of the following values for @rowcount_only:
- 1 - Rowcount check only (the default)
- 2 - Rowcount and binary checksum.
[!참고] To successfully execute sp_article_validation(Transact-SQL), you must have SELECT permissions on all columns in the published base table.
At the Publisher on the publication database, commit the transaction using COMMIT TRANSACTION(Transact-SQL).
(Optional) Repeat steps 1 through 5 for each article being validated.
(Optional) Start the Distribution Agent if it is not already running. For more information, see 방법: 끌어오기 구독 동기화(Replication Programming) and 방법: 밀어넣기 구독 동기화(Replication Programming).
Check the agent output for the result of the validation. For more information, see 방법: 구독자에서 데이터 유효성 검사(SQL Server Management Studio).
To validate data in all subscriptions to a merge publication
At the Publisher on the publication database, execute s sp_validatemergepublication(Transact-SQL). Specify @publication and one of the following values for @level:
- 1 - Rowcount-only validation.
- 3 - Rowcount binary checksum validation.
This marks all subscriptions for validation.
Start the merge agent for each subscription. For more information, see 방법: 끌어오기 구독 동기화(Replication Programming) and 방법: 밀어넣기 구독 동기화(Replication Programming).
Check the agent output for the result of the validation. For more information, see 방법: 구독자에서 데이터 유효성 검사(SQL Server Management Studio).
To validate data in selected subscriptions to a merge publication
At the Publisher on the publication database, execute sp_validatemergesubscription(Transact-SQL). Specify @publication, the name of the Subscriber for @subscriber, the name of the subscription database for @subscriber_db, and one of the following values for @level:
- 1 - Rowcount-only validation.
- 3 - Rowcount binary checksum validation.
This marks the selected subscription for validation.
Start the merge agent for each subscription. For more information, see 방법: 끌어오기 구독 동기화(Replication Programming) and 방법: 밀어넣기 구독 동기화(Replication Programming).
Check the agent output for the result of the validation.
Repeat steps 1 through 3 for each subscription being validated.
[!참고] A subscription to a merge publication can also be validated at the end of a synchronization by specifying the -Validate parameter when running the Replication Merge Agent.
To validate data in a subscription using Merge Agent parameters
Start the Merge Agent at the Subscriber (pull subscription) or at the Distributor (push subscription) from the command prompt in one of the following ways.
- Specifying a value of 1 (rowcount) or 3 (rowcount and binary checksum) for the -Validate parameter.
- Specifying rowcount validation or rowcount and checksum validation for the -ProfileName parameter.
For more information, see 방법: 끌어오기 구독 동기화(Replication Programming) or 방법: 밀어넣기 구독 동기화(Replication Programming).