I am planning to migrate a large database table from our main SQL database to a separate one. Because it's a high volume/one time process, I'm going to use SSIS. Does anyone know how best to time migrating all the data and changing the code's connection string?
Quick background: Our system uses a table to log every notification that is sent out. The code to send out the notifications runs every half hour. This table doesn't have any updates or deletes, just inserts and selects. Before sending out a notification, we do a select on this table as a definite check that we're not sending duplicates.
My basic plan right now is to do the following:
- Move all the data the the new database using SSIS. (Could take a long time)
- Wait til that's completed. Then, turn off the notification service.
- Update the code with the new connection strings.
- Move any data that was inserted between the SSIS package completed and when I turned off the notifications. (Probably won't take long - not much new data)
- Turn the notification service back on.
Is this the best way to do it, or is there a better way?
Also if I do it this way, I'm not sure the best way to migrate only new data (step 4). Ideally, I could set it to "insert only if it doesn't already exist", but I'm not sure if that's an option with SSIS. My idea right now is to move the big chunk of data (step 1) with a query (select * where InsertedOn < @SomeDate), then move the rest with another query (select * where InsertedOn >= @SomeDate).