Monday, February 20, 2012

Merging two databases into one

I currently have two databases which contain the same database structure
but different data. How do I merge the two databases into one single
database?
*** Sent via Developersdex http://www.developersdex.com ***You can do it using T-SQL queries.
How do you want to merge the data? Just copy all the data from dbA to dbB or
all the data from dbB to dbA. Do you have to resolve any conflicts? that is,
could the same key can have different data in different databases?
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Enoch Chum" <enoch.chum@.wcb.ab.ca> wrote in message
news:ucNXVxIlFHA.1968@.TK2MSFTNGP14.phx.gbl...
>I currently have two databases which contain the same database structure
> but different data. How do I merge the two databases into one single
> database?
>
> *** Sent via Developersdex http://www.developersdex.com ***|||Hi,
To add on to Vyas, Incase if you have same table definitions in both
databases and different data then use:-
Insert into DBnameA..Tablename select * from DBnameB..tablename where
condition...
Do the above for all tables.. In your query take care of constraints as well
as identity.
Thanks
Hari
SQL Server MVP
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:OGmJfFPlFHA.2860@.TK2MSFTNGP15.phx.gbl...
> You can do it using T-SQL queries.
> How do you want to merge the data? Just copy all the data from dbA to dbB
> or all the data from dbB to dbA. Do you have to resolve any conflicts?
> that is, could the same key can have different data in different
> databases?
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "Enoch Chum" <enoch.chum@.wcb.ab.ca> wrote in message
> news:ucNXVxIlFHA.1968@.TK2MSFTNGP14.phx.gbl...
>>I currently have two databases which contain the same database structure
>> but different data. How do I merge the two databases into one single
>> database?
>>
>> *** Sent via Developersdex http://www.developersdex.com ***
>

No comments:

Post a Comment