开发者

Copy Database Data from Many DBs to One. Data Replication (sort of)

开发者 https://www.devze.com 2022-12-17 21:04 出处:网络
This involves data replication, kind of: We have many sites with SQL Express installed, there is an \'audit\' database on each site that has one table in 1st normal form (to make life simple :)

This involves data replication, kind of:

We have many sites with SQL Express installed, there is an 'audit' database on each site that has one table in 1st normal form (to make life simple :)

Now I need to get this table from each site, and copy the contents (say, with a Date Time Value > 1/1/200 00:00, but this will change obviously) and copy it to a big 'super table' in sql server proper, that also has the primary key as the Site Name (That needs injecting in) and the current primary key from the SQL Express table开发者_运维知识库)

e.g. Many SQL Express DBs with the following table columns

ID, Definition Name, Definition Type, DateTime, Success, NvarChar1, NvarChar2 etc etc etc

And the big super table needs to have:

SiteName, ID, Definition Name, Definition Type, DateTime, Success, NvarChar1, NvarChar2 etc etc etc

Where items in bold are the primary key(s)

Is there a Microsoft (or non MS I suppose) app/tool/thing to manager copying all this data accross already, or do we need to write our own?

Many thanks.


You can use SSIS (which comes with SQL Server) to populate, it can be set up with variables to change the connection string to the various databases. I have one that loops through the whole list and does the same process using three differnt files from three differnt vendors. You could so something simliar to loop through the different site databases. Put the whole list of database you want to copy the audit data from in a table and loop through it changing the connection string each time.

However, why on earth would you want one mega audit table per site? If every table in the database populates the audit table as changes happen, then the audit table eventually becomes a huge problem for performance. Every insert, update and delete has to hit this table and then you are proposing to add an export on top of that. This seems to me to be a guaranteed structure for locking and deadlocks and all sorts of nastiness. Do yourself a favor and limit each audit table to the table it is auditing.


Things to consider: Linked servers and sp_msforeachdb as part of a do-it-yourself solution. SQL Server Replication (by Microsoft) (which I believe can pull data from SQL Server Express) SQL Server Integration Services which can pull data from SQL Server Express instances.

Personally, I would investigate Integration Services first.

Good luck.


You could do this with SymmetricDS. SymmetricDS is open source, web-enabled, database independent, data synchronization/replication software. It uses web and database technologies to replicate tables between relational databases in near real time. The software was designed to scale for a large number of databases, work across low-bandwidth connections, and withstand periods of network outage.

As of right now, however, you would need to implement a custom IDataLoaderFilter extension point (in Java) to add the extra column. The metadata would be available though because your SiteName would be the external_id.

0

精彩评论

暂无评论...
验证码 换一张
取 消