INSERT statement conflicted with the FOREIGN KEY constraint - SQL Server

前端 未结 14 1261
-上瘾入骨i
-上瘾入骨i 2020-11-22 11:09

I am getting the following error. Could you please help me?

Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the FOREIGN

14条回答
  •  情深已故
    2020-11-22 11:58

    Something I found was that all the fields have to match EXACTLY.

    For example, sending 'cat dog' is not the same as sending 'catdog'.

    What I did to troubleshoot this was to script out the FK code from the table I was inserting data into, take note of the "Foreign Key" that had the constraints (in my case there were 2) and make sure those 2 fields values matched EXACTLY as they were in the table that was throwing the FK Constraint error.

    Once I fixed the 2 fields giving my problems, life was good!

    If you need a better explanation, let me know.

提交回复
热议问题