sql-server - 将 Identity_insert 设置为 on - 合并复制

标签 sql-server sql-server-2005 replication merge-replication

我在两个数据库之间设置了合并复制,并在两个数据库上使用身份范围。

我想将特定行添加到发布者上的合并表(将标识值设置为标识范围之外的值)。当我尝试此操作时,出现以下错误。

The insert failed. It conflicted with an identity range check constraint in database 'xxx', replicated table 'dbo.yyy', column 'yyy_id'. If the identity column is automatically managed by replication, update the range as follows: for the Publisher, execute sp_adjustpublisheridentityrange; for the Subscriber, run the Distribution Agent or the Merge Agent.

有没有办法强制将特定标识值放入使用标识范围管理的合并复制表中?

最佳答案

一种方法是确保复制拓扑中的每个节点都使用不同范围的标识值,以便不会发生重复。

For example, the Publisher could be assigned the range 1-100, Subscriber A the range 101-200, and Subscriber B the range 201-300. If a row is inserted at the Publisher and the identity value is, for example, 65, that value is replicated to each Subscriber. When replication inserts data at each Subscriber, it does not increment the identity column value in the Subscriber table; instead, the literal value 65 is inserted. Only user inserts, but not replication agent inserts cause the identity column value to be incremented.

引用号。 Replicating Identity Columns

关于sql-server - 将 Identity_insert 设置为 on - 合并复制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/638714/

相关文章:

sql - DBOwner 给另一个 SQL Server 用户

sql - 从数据库表中获取行的最大值

mysql - 如何在 CentOS 7 上引导 MariaDB 集群?

sql - 去年的 YTD 编号查询

sql-server - 仅返回具有存储过程的数据库名称

sql-server - 您会使用什么类型的算法来帮助根据历史数据预测 future 的表现?

r 中其他列的数字复制

C# Enum 使用 Sql Server 表中的值

c# - 如何在 Dataset DataTable 中显示 DataColumns

sql-server - 如何将 postgresql 转储恢复到 SQL Server 实例?