Foreign Key constraint issue

  • Morning everyone!  Next question:

    I am doing an insert into a table.  There is a foreign key constraint to another table.  I am getting an error on the insert.  I checked the other table and the PersonID is there, so I don't know why I am getting this error....any help????  here is the error:

    Server: Msg 547, Level 16, State 1, Line 163

    INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_PersonAllergy_Person'. The conflict occurred in database 'Medicompass31', table 'Person', column 'PersonID'.

    The statement has been terminated.

    thank you!! 


    Thank you!!,

    Angelindiego

  • what kind of field is PersonId? char, varchar, int?

    Are you checking the right table? (have you specified an owner like dbo)

  • We'd need to see the DDL code (CREATE TABLE statements).

    You might already know this, but in Query Analyzer, if you make the Object Browser visible, you can drill down to the table(s), right click on the table, select "Script Object to Clipboard as Create" and then paste this code.

    Then we can debug with you.

  • Can you specify the primary key of the parent table.

    I guess the column in the child table is not accepting any nulls.

    ..hema

  • No, the issue here is USER ERROR!!!  Geez, I was trying to insert into the wrong database!!  What an idiot....sorry everyone!!  But.....I have another issue that you can help me with so I will post it now!!  Thanks you guys!!


    Thank you!!,

    Angelindiego

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply