问题描述
我收到以下错误.你能帮我吗?
I am getting the following error. Could you please help me?
消息 547,级别 16,状态 0,第 1 行
INSERT 语句与 FOREIGN KEY 约束FK_Sup_Item_Sup_Item_Cat"冲突.冲突发生在数据库dev_bo"、表dbo.Sup_Item_Cat"中.声明已终止.
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.. 但没有喜悦 :-(
The last column client_id is causing the error. I tried to put the value which already exists in the dbo.Sup_Item_Cat into the column, corresponding to the sup_item.. but no joy :-(
推荐答案
在您的表 dbo.Sup_Item_Cat 中,它有一个指向另一个表的外键引用.FK 的工作方式是,它不能在该列中具有不在引用表的主键列中的值.
In your table dbo.Sup_Item_Cat, it has a foreign key reference to another table. The way a FK works is it cannot have a value in that column that is not also in the primary key column of the referenced table.
如果您有 SQL Server Management Studio,请打开它并sp_help 'dbo.Sup_Item_Cat'.查看 FK 位于哪一列,以及它引用哪个表的哪一列.您插入了一些错误数据.
If you have SQL Server Management Studio, open it up and sp_help 'dbo.Sup_Item_Cat'. See which column that FK is on, and which column of which table it references. You're inserting some bad data.
如果您需要更好的解释,请告诉我!
Let me know if you need anything explained better!
这篇关于INSERT 语句与 FOREIGN KEY 约束冲突 - SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)