【问题标题】:MERGE conflict foreign key constraintMERGE冲突外键约束
【发布时间】:2017-12-31 13:16:41
【问题描述】:

我使用MERGEUPDATEINSERT 数据进入我的数据库。但是当我 MERGE 进入我的表 xx_MaterialDataxx_MaterialDataxxx 时,我得到如下所示的 FK 错误。

The MERGE statement conflicted with the FOREIGN KEY constraint 
"FK_xx_MaterialData_xxxx_Material". The conflict occurred in database 
"TEST", table "dbo.xxxx_Material", column 'xxxxxGUID'.

The MERGE statement conflicted with the FOREIGN KEY constraint 
"FK_xx_MaterialDataxxx_xxxx_MaterialText". The conflict occurred in
database "TEST", table "dbo.xx_MaterialData", column 'xxxxxGUID'.

我已经尝试了 MERGE 语句的不同顺序,但没有帮助。我首先尝试了xxxx_Material,然后是孩子们。或者先是孩子xx_MaterialDataxxx,然后是xx_MaterialData,然后是xxxx_Material

依赖项如下: xxxx_Material > xx_MaterialData > xx_MaterialDataxxx
xxxx_Material > xxxx_MaterialText
xxxx_PriceList > xx_MaterialDataxxx

有人知道我还能做什么吗?我有另一个具有相同结构但数据不同的数据库,我没有问题。

MERGE 语句的正确顺序是什么?也许我做错了什么?

【问题讨论】:

标签: sql sql-server merge foreign-keys constraints


【解决方案1】:

显然语句的顺序仍然存在问题。再次将它们按正确的顺序排列后,它就起作用了。

【讨论】:

    猜你喜欢
    • 2018-07-26
    • 2017-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    • 1970-01-01
    • 2018-10-12
    相关资源
    最近更新 更多