且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-02-25 21:50:10

在表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!