gpt4 book ai didi

sql - INSERT 语句与 FOREIGN KEY 约束冲突 - SQL Server

转载 作者:行者123 更新时间:2023-12-01 16:25:02 27 4
gpt4 key购买 nike

Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Sup_Item_Sup_Item_Cat". The conflict occurred in database "dev_bo", table "dbo.Sup_Item_Cat". The statement has been terminated.

insert into sup_item (supplier_id, sup_item_id, name, sup_item_cat_id, 
status_code, last_modified_user_id, last_modified_timestamp, client_id)
values (10162425, 10, 'jaiso', '123123',
'a', '12', '2010-12-12', '1062425')

最后一列 client_id 导致了错误。我尝试将 dbo.Sup_Item_Cat 中已存在的值放入与sup_item相对应的列中。

最佳答案

您的表dbo.Sup_Item_Cat具有对另一个表的外键引用。 FK 的工作方式是,该列中的值不能不在引用表的主键列中。

如果您有 SQL Server Management Studio,请打开它并sp_helpdbo.Sup_Item_Cat”。查看 FK 位于哪一列,以及它引用哪个表的哪一列。您正在插入一些错误数据。

关于sql - INSERT 语句与 FOREIGN KEY 约束冲突 - SQL Server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2965837/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com