Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Merge databases

Author  Topic 

guaro5555
Starting Member

16 Posts

Posted - 2013-05-29 : 15:18:38
Hi gurus

Here is what I would like to achieve and I am new to SQL so go easy on me.

I have an instance which has multiple databases, this database are exactly in structure as they are created by a third party application every month.
I would like to merge,combine this monthly databases into a year databases, so this will meant to merge jan-dic into 2012 database, can someone help me on this journey please

Thanks a bunch

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-29 : 15:55:04
I don't know of an automated way to merge two databases which have tables that have the same names, constraints etc. Conceivably, one could create a new database with the same schema, and then import all the tables in each database to this new database one at a time (you can use import/export wizard or SSIS to do this).

However, that may not always work smoothly and you might have to do more work, for example:

- presence of identity columns that have unique constraints on them (you will have to exclude the identity column from import and let the new database assign identity values)
- foreign key constraints that may prevent the importing unless done in the correct order or unless you disable constraint checking

etc.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-30 : 01:28:44
Why not use partitions to store monthly data instead of using separate dbs for each. That would be much easier to merge. Anyways current you have it you've to manually do the creation of new db as well as the merging of data from old. You can do it via T-sql scripts or SSIS for that.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -