How to merge 2 SQL databases

Asked By 10 points N/A Posted on -
qa-featured

 

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
 
SHARE
Answered By 30 points N/A #137973

How to merge 2 SQL databases

qa-featured

 

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.

Related Questions