Foreign key constraint error

  • Hi Friends,

    I have a data flow which is going to insert some rows in a table...A column in the table is referenced as a foreign key....when i am executing it gives foreign key constraint error...where there is no rows presented in the referenced table...i don't know why it is?

    help me by your suggestions friends...

    Thanks,
    Charmer

  • I think you had an "Execute SQL Task", so to correct this error, an alternative is to make a EvenHadler "Send Mail Task", this will send you and Email with the error which is: Empty Table.

    The Expression properties of the Send Mail Task will be:

    -@[User::varMailTo]

    -"Error Desc: " + @[System::ErrorDescription] + " Source Name: " + @[System::SourceName]

    -"SSIS Package Error From: " + @[System::MachineName]

    You only have to create a variable "varMailTo".

    With this the "Execute SQL Task" will appear as red as usual, but the eventhandler will catch this error, send you an email, and terminate the process succesfully.

    See Yaa

  • Also, you have to make sure that you have create the tables that you used in the DB. with the corresponding Keys

  • In sqlserver, you cannot have a child without having a parent, at least if the FK constraint is in place !

    Leave it in place !

    Just double check you load the parent table rows first and only then load the child table rows.

    With ssis you can route the faulty rows to an error bucket.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

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

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