views:

117

answers:

8

A vendor has a data database (read only) that gets sent to us via dvd every week. Their upgrade script detaches the existing copy of the database, overwrites the MDF and LDF, drops all the users and recreates what they think proper security should be. Is there a way that I can just synchornize the data without taking the database offline? This is a 24/7 facility that causes 15 minutes of downtime during the updates.

Auxilary Information: The database has ~50 tables with a total size of 400 MB. The actual amount of changed data is somewhere around 400kb. Server is running Server 2008 with SQL Server Enterprise Edition 2008.

A: 

You could write your own program that connects to both the vendor supplied database and your own (possibly a DTS, or a C# app) and has some intelligence about which data should be moved/migrated from the vendor DB into your own.

Jason Whitehorn
+5  A: 

Read up on Red Gate Data Compare

http://www.red-gate.com/products/SQL_Data_Compare/index.htm

This will generate a script of differences for you that you can apply to the existing database.

This also has the ability to automatically synchronize your data

You will have to load the incoming database to a server for this operation.

Raj More
Couldn't live without the RedGate tools when working with SQL Server. If it's just 400k of data that's changing, a live update should be fine. You could even script the build, backup and run the compare/ sync.
Tom
These tools scare me a bit.... Can you compare data on high-use live databases without locking up tables ?
Hassan Syed
Won't that generate a complete shedload of logs for no useful purpose? Also, if you do a live update, you're going to make all the changes and issue a single commit? DO you have the space required to do that or will you be allowing dirty reads? So any queries in the process will get confusing data with some of the old rows and the new rows?
Stephanie Page
OK I just saw the 400MB, and not the 400Kb... agreed. Just make sure there's none but one commit at the end. Oh right this is SQL Server... turn on consistent read if your system can handle that.
Stephanie Page
This worked extremely well. Thank you for the recommendation.
Mitch
A: 

You could load the db as a separate database and then use a utility like SQL Data Compare to diff the data differences and generate a script.

RedFilter
A: 

This should be a backup/restore operation. Detach/reattach is quick and easy but obviously takes the database offline.

Alternatively, they can provide diff scripts to update any data and schema changes that they require. Run the scripts (basically a bunch of create, alter, adds and drops for schema changes, along with inserts for new data) on the active database to bring it up to date. This has the advantage that the scripts can be easily version controlled.

David Lively
A: 

You could synchronize the data using a tool like Red-Gate Data Compare.

Randy Minder
+4  A: 

Something you can do is to have two databases DB_A and DB_B when they send you the new DB you install it and replace DB_B. In the meantime all your users are using DB_A. Then rename the DB_A to DB_C and rename DB_B to DB_A. That will decrease the downtime to almost 0. Or you can just change the connection to point from DB_A to DB_B once the DB is ready.

Jose Chama
You cannot rename a database while connections are open. You have to set the db to single user mode first (but have to wait until no users are in the database / force all users out), make the swap and set it back to multi user mode.
Raj More
+1  A: 

Can't believe no one has mentioned this method.

KISS: You could load the restore (or attach) the DB to a new catalogue and then reconfigure your apps (for example through a ODBC DSN) to work with the new DB -- once you the rollover is done you can detach the old one. This method is called the "Rolling upgrade" and is used all over the place for 24/7 sites.

Hassan Syed
A: 

You can use SSIS to create a data import/update process. One question I would have before doing this would be what would be the issue if during a short period of time table has new data and table b has not been updated? Must all the data stay in synch? Follow Jose Chama's advice if you can;t have things out of synch even for a minute.

HLGEM