I'm creating a data transfer utility. One thing it has to do is disable foreign keys while deleting and inserting data. Is there a way to disable foreign keys on referencing tables so the constraint isn't evaluated? I'm hoping there is a way to switch it off as oppose to dropping and creating.
Customer AddressID - Foreign key to Address
Which do I do first? If I delete from Customer then insert I may be inserting records with an AddressID that doesn't exist in Address (foreign key constraint). If I delete from Address (automatic foreign key constraint).
I can't delete everything table then start inserting. It has to be a Delete\Insert pair.
Some time ago I need something like this. I solved this problem calculating and generating an import order.
answered 27 Aug '10, 23:44