自动解决主键合并冲突 [英] Automatically resolve primary key merge conflict

查看:72
本文介绍了自动解决主键合并冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能建议我自动解决的方式吗发布者和订阅者合并期间的主键冲突.似乎 Sql Server 并没有开箱即用 :(.

could you please suggest me the way I could automatically resolve primary key conflicts during a merge between Publisher and Subscriber. It seems Sql Server doesn't do it out of the box :(.

冲突查看器向我显示下一条消息:

Conflict viewer shows me next message:

无法将_publisher_server_"处的行插入传播到_subscriber_server_".此失败可能是由违反约束引起的.违反 PRIMARY KEY 约束PK_PartPlan_FD9D7F927172C0B5".无法在对象_table_name_"中插入重复键.

A row insert at '_publisher_server_' could not be propagated to '_subscriber_server_'. This failure can be caused by a constraint violation. Violation of PRIMARY KEY constraint 'PK_PartPlan_FD9D7F927172C0B5'. Cannot insert duplicate key in object '_table_name_'.

谢谢.

推荐答案

这不是一个简单的解决方案(因为您可能已经设计了具有自动递增 int 键的数据库),但是为主键使用 GUID(唯一标识符")将解决您的 PK 冲突问题.

This isn't an easy solution (since you've presumably already designed your database with auto-incrementing int keys), but using GUID ("uniqueidentifier") for your primary keys will solve your PK collision problem.

这篇关于自动解决主键合并冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆