The INSERT statement conflicted with the FOREIGN KEY constraint ... SQL SERVER
Posted on 2011-10-03
I am in the process of populating a relational database in sql and migrating data from a none relational database.
I get error message: "The INSERT statement conflicted with the FOREIGN KEY constraint ...."
for some of tables.
It happens when the relationship between the two table is like:
LookupTbl (1: M ) childTbl
UnitOfMesure (PK) Name
sample records in Lookuptbl are: Meter, Inch
some of the old tables I am using as a source for migration do not have UnitOfMeasure column at all, so I have added them to the tables before doing the migration but they are obviously empty and have no value.
When I try to import data into childTbl, I keep getting this error message:The INSERT statement conflicted with the FOREIGN KEY constraint ....
I have been testing the migration, so I have deleted the tables and tried to populate them again and again and I am not sure why a column which can be NULL is causing problem...
Thanks in advance