复制 SQL Server

发布于 2024-09-06 21:32:53 字数 215 浏览 4 评论 0原文

在我的生产服务器中,我有复制,工作正常,我有分布式数据库,作为 2 个订阅者 db 。 我的数据是从生产环境复制的(工作正常),但同时 数据被复制到订阅服务器中的分布式数据库,它会抛出错误

Err msg =
复制-复制分发子系统:PRD01-XYZ-VREPL1\REPL01-25 失败。 违反主键约束“PK_vendors”。 无法在对象“dbo.tabname”中插入重复的键。

In my Production Server i have replication which working fine, i do have Distributed Database which as 2 subscriber db .
My data is replicated from Production envi (working fine) but while
data gets replicated to Distributed database in Subscriber it throws an Error

Err msg =
Replication-Replication Distribution Subsystem: PRD01-XYZ-VREPL1\REPL01-25 failed.
Violation of PRIMARY KEY constraint 'PK_vendors'.
Cannot insert duplicate key in object 'dbo.tabname'.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…楫夜泊 2024-09-13 21:32:53

我已经有一段时间没有这样做了,但这是一个尝试。

首先,我不介意看到不匹配的记录,所以我会尝试这样的事情:

--to be run on the publisher
select pub.*, sub.*
from 
    db_name1.dbo.tabname pub
    JOIN linked_server_to_subscriber.db_name1.dbo.tabname sub
        ON pub.pk = sub.pk
WHERE
    pub.some_field != sub.some_field

希望对于“some_field”,有另一个唯一的列,或者可能是 dt_entered,或者可能是 rowguid。 :)。

最后,如果您的情况的逻辑涉及记录如果通过复制以外的方式插入订阅者表,并且复制类型不是合并,那么您很可能会继续遇到这样的问题。

祝你好运。

I haven't done this in a while, but here is a stab.

First, I wouldn't mind seeing the records which aren't matching, so I would try something like this:

--to be run on the publisher
select pub.*, sub.*
from 
    db_name1.dbo.tabname pub
    JOIN linked_server_to_subscriber.db_name1.dbo.tabname sub
        ON pub.pk = sub.pk
WHERE
    pub.some_field != sub.some_field

Hopefully, for "some_field", there is another unique column, or perhaps a dt_entered, or perhaps a rowguid. :).

Finally, if the logic of your situation involves records being inserted into the subscriber table other than by replication, and the type of replication is not merge, you may very well continue to have problems like this.

Good luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文