Failed to copy due to data conflicts in SQL Server replication

Source: Internet
Author: User

SQL Server replication is a commonly used feature to improve performance and availability. However, there are many unstable factors in this feature, which may cause the failure of the replication function, today, I encountered a problem because of the transaction replication failure caused by SQL Server data conflicts. To solve this problem, reinitialize replication to ensure data consistency on both sides. You can also skip failed transactions, so that although some data may be inconsistent, if you can ensure that this part of data is not critical data, you can use this solution.

To skip a failed transaction, two SP s are required. The first is sp_helpsubscriptionerrors, which is used to query which transaction causes data conflict. This stored procedure is executed in the distributor's distribution database.

Syntax

Copy

Sp_helpsubscriptionerrors [@ publisher =] 'her her ', [@ publisher_db =] 'her her _ db', [@ publication =] 'publication', [@ subscriber =] 'subscriber ', [@ subscriber_db =] 'subscriber _ db'

In the returned tableXact_seqnoThe column is the transaction ID we are looking.

In this case, we can use our second SP: sp_setsubscriptionxactseqno.

Syntax

Copy

Sp_setsubscriptionxactseqno [@ publisher =] 'her her ', [@ publisher_db =] 'her her _ db', [@ publication =] 'publication', [@ xact_seqno =] xact_seqno

This stored procedure is executed on the subscription server (Business Database. The non-SQL Server subscription server does not support this process.

After the transaction is successfully executed, you can skip the transaction and copy the transaction to continue the execution. Of course, it is best to verify whether there is a missing or inconsistent key data after the replication fix.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.