【发布时间】:2010-02-02 07:01:51
【问题描述】:
我正在尝试将几千行插入到跨两台服务器复制的数据库中的表中。无论是发布者还是订阅者,我都会收到相同的错误:
Msg 548, Level 16, State 2, Line 1
The insert failed. It conflicted with an identity range check constraint in database 'XXX', replicated table 'dbo.NODE_ATTRIB_RSLT', column '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.
The statement has been terminated.
检查表上的约束,在我看来,我应该能够在遇到问题之前一次插入至少 1000 行。但是,尝试仅插入几十行时,我得到了同样的错误!
这是我尝试插入数据的方式:
insert into NODE_ATTRIB_RSLT
([NODE_ID]
,[ATTRIB_ID]
,[STATE_ID]
,[PLAN_REVISION_ID]
,[TIMESTAMP]
,[VALUE]
,[VALUE_TEXT]
,[LAST_MODIFIED])
SELECT [NODE_ID]
,[ATTRIB_ID]
,[STATE_ID]
,[PLAN_REVISION_ID]
,[TIMESTAMP]
,[VALUE]
,[VALUE_TEXT]
,[LAST_MODIFIED] FROM [NODE_ATTRIB_RSLT_TEMP]
PK 列是一个自动生成的身份,称为 ID。为了尝试一次插入更少的行,我在 select 的末尾添加了一个 WHERE 子句,如下所示:
WHERE ID >= 1000 and ID <1100
但无济于事。
在 Publisher 上运行 sp_adjustpublisheridentityrange 成功执行但没有效果。
如何解决插入问题? 如何在保持复制运行的同时将缩进范围约束的范围修改为更合理的水平?
【问题讨论】:
标签: sql-server tsql