Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

What is INSERT statement conflicted with the FOREIGN KEY constraint?

If your are getting following error,

The INSERT statement conflicted with the FOREIGN KEY constraint "ABC". The conflict occurred in database "XYZ", table "XYZ", column 'Id'.

 Solution:

For example your database has two tables


Leave table LeaveType is foreign key and Primary Key in LeaveType table is ID, When you try to enter Leave type that is not exist in First Table(LeaveType) you will get above error.

i.e when you try to enter data like following


Solution for this error is while inserting data into second table use only existing data (data from Primary Kay table).

 

Share your answer


Share as a guest

Please subscribe me to the CodeChef4U.

By creating your new answer, you agree to the privacy policy and terms of service.