The ALTER TABLE statement conflicted with the FOREIGN KEY constraint
Try this solution:
There is a data item in your table whose associated value doesn't exist in the table you want to use it as a primary key table. Make your table empty or add the associated value to the second table.
It is possible to create the foreign key using ALTER TABLE tablename WITH NOCHECK ..., which will allow data that violates the foreign key.
"ALTER TABLE tablename WITH NOCHECK ..." option to add the FK -- This solution worked for me.
This query was very useful for me. It shows all values that don't have any matches
select FK_column from FK_table WHERE FK_column NOT IN (SELECT PK_column from PK_table)
It occurred because you tried to create a foreign key from
tblBana.BanNR but/and the values in
tblDomare.PersNR didn't match with any of the values in
tblBana.BanNR. You cannot create a relation which violates referential integrity.