Options

foreign key question

jbenckertjbenckert Posts: 2
Newbie here. I'm playing with the trial and I've modified the worked example in the api documentation to run against some play databases.

I have a parent and child table with a foreign key relationship. Both tables have primary keys that are identities.

When the sql data compare script is created to insert the records into the new database, the parentID in the child table is being inserted 'as is' from the old table rather than inserting the parent record and inserting the child records with the new ID from the parent. Is there any way to do this programatically?

Thanks in advance for any help.

Comments

  • Options
    You could switch on the 'Drop primary keys, indexes, and unique constraints' option and create a comparison key between the parent and child consisting of an aggregate of all the row data except for the PK, ignoring the PK's altogether. In this way the parent-child data variance will be seen by SQL Data Compare, and when synchronised
    PK identity field will be repopulated automatically.
    Chris Buckingham
    Red-Gate support
Sign In or Register to comment.