Insert Statement Conflicted With the Foreign Key Constraint - SQL Server

INSERT statement conflicted with the FOREIGN KEY constraint - SQL Server

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.

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 statement conflict with the foreign key

Since You don't have any data in director table you can't perform entry to movie table(because of foreign key reference) so first enter some data into the director table then enter data into movie table

For more details you can refer to this link
INSERT statement conflicted with the FOREIGN KEY constraint - SQL Server

My INSERT statement conflicted with the FOREIGN KEY constraint

In your table [dbo].Hastalar, 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.

If you have SQL Server Management Studio, open it up and sp_help '[dbo].Hastalar'. See which column that FK is on, and which column of which table it references. You're inserting some bad data.

INSERT statement conflicted with the FOREIGN KEY constraint - SQL

Here is your insert statement:

INSERT INTO Title (ISBN, Title, CategoryCode, PublisherCode, SuggestedPrice, NumberInStock)
VALUES ('1021031040', 'PL SQL', 1, 200, 75.50, 10);

The error message seems to be saying that there is no record in the publisher table whose primary key is 200. That is, your insert is referring to a publisher record which does not exist. The remedy would be to either not do this insert, or to add a record to the publisher table with an id of 200.



Related Topics



Leave a reply



Submit