views:

40

answers:

3

Hi all.

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.

+1  A: 

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.

Michael J Swart
Thanks for that, I will take a look at each and get back with the solution I I chose.
adudley
Using SSIS is working really nice, thank you. you can have a data source and have a derived column which lets you add pretty much anything. Fantastic, and it can loop through and connect to all sorts of things.
adudley
+1  A: 

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.

HLGEM
Thanks for pointing me to SSIS I will look into that. The 'Audit' Table is not so much an audit of what happens to the DB, but an audit of what happens on the system. e.g. User XYZ saved config page ABC. User ASD deleted configiured item Y. User B has logged on. etc.And the mega audit table will be a copy of all the smaller ones from all the sites, so that people can run reports on it in a timely manor (slowish networks you see!)Thanks again.It's not really that big
adudley
+1  A: 

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.

chenson42
Open source is a bit of a no-go for our client, and SSIS does what I need out of the box (with some learning), but thank you for the heads up, since I use OS stuff for all other projects where possible :)
adudley