我正在尝试从表中删除数据,但出现以下错误
DELETE语句与REFERENCE约束冲突 “ FK_TradingPartnerControlID_TPGRU”。数据库中发生了冲突 “ GRiDSCore”,表“ dbo.TradingPartnerGRU”,列 “ TradingPartnerControlID”。
Begin Tran
Delete TradingPartnerControl
FROM TradingPartnerGlobalGroup tpgg
JOIN TradingPartnerGroup tpg ON tpg.TradingPartnerGlobalGroupID =
tpgg.TradingPartnerGlobalGroupID
JOIN TradingPartnerControl tpc ON tpc.TradingPartnerGroupID =
tpg.TradingPartnerGroupID
JOIN TradingPartnerGRU tpgru ON tpgru.TradingPartnerControlID =
tpc.TradingPartnerControlID
JOIn messagecontrol mc on mc.tradingpartnergruid=tpgru.tradingpartnergruid
where tpc.TradingPartnerControlID between '34' and '39'
--Rollback
我想从Table TradingPartnerControl中删除其中TradingpartnerID在'34'和'39'之间的数据
答案 0 :(得分:1)
从显示的错误来看很清楚。这是由于要从中删除表中的列上的外键约束所致。要么先删除引用表中的记录,要么使用CASCADE ...