merge rows with foreign keys

rperry_wha
rperry_wha used Ask the Experts™
on
I have a table with 2 rows that need to be merged (duplicate entry) but I'm using foreign keys.  I want to preserve and update the data in the other tables, how can I do this?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
First of all update foreign keys in other tables, they have to point just to one of two duplicate rows. Then you may delete the row which is not referenced by foreign keys. If you have some foreign keys in the row which should be deleted then you may delete corresponding master records as well BUT only if they are not referenced from other records elsewhere.

The best way is to do this work manually via some client connection to your database. If you have all primary and foreign keys properly defined then any deletion must check these references and refuse your attempts to remove data which "in use".

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial