Asked By
Jean Moore
10 points
N/A
Posted on - 02/08/2013
Â
Hi guys, I am into database programming and I am using sql as my database. I need you help, can you answer this question. How to merge 2 sql databases? Thanks for your help
Â
How to merge 2 SQL databases
Â
Hi there.
Â
The easiest way to merge to databases into one is to use a third party software. Red Gate SQL Data Compare will do the trick and save you plenty of time and trouble. It will check for differences between first and second base and merge them to one giving you the option to fully control how and what to be placed where.
Â
If you are into manual solution, there is no easy way to do that. Your databases should use auto generated keys. Firstly you have to add a new auto generated key to the parent table. After that import all the data from both tables and adjust names so they all have the same prefix. After your parent table is done, you have to join all the child tables to the new parent table taking the new id field as the value for every foreign key. Repeat that process for every new key table, even if the table is also the parent table.
Â
Before you enter any data to your child tables, you have to add the new, conversionid field to your new table.
Â
In case you are using natural keys, be ready for some duplicates you'll have to clean manually.