SSIS - Deactivate Records in Destination not Contained in Results from Source

  • Hello,

    I am working on a few SSIS packages translating data from our enterprise source system database to our new website database. Our source system deletes data from tables quite often. Because the data exists on the website from previous package executions, the deleted rows either needs to be deactivated or deleted on the website accordingly (depending on which tables have the active flags to retain deleted data).

    What is the recommended way of accomplishing this?

    I am trying to avoid having to run the source query twice to our enterprise database for every package and execute two different Data Flow Tasks. Furthermore, the databases are not, and cannot, be linked to do cross-database queries. I am also trying to avoid truncating tables and re-syncing each time as there is a lot of data being moved and the website will be pretty active, not to mention there may be data to integrate the other direction in these tables.

    Thank you for your time and expertise,

    Rob K.

  • Hello Rob,

    I assume that you cannot use or don't want to use Transactional Replication or Change Data Capture against your Source System database(s)? (Note: CDC is only available from SQL Server 2008 onward and then only in Developer and Enterprise Editions).

    If you are doing everything with SSIS packages then could write a package (or series of packages) that start with your Website database and look up data in your Source System database(s). any non-matching rows indicate that a row that exists in the Website database no longer exists in the Source System database and can therefore be marked for deletion/deactivation or deleted.

    Clearly, the more data that you have, the longer a process like this is going to take so you may want to minimise the amount of data that you are working with by only selecting from both databases (Source System and Website) the column(s) that uniquely identify a row. An alternative is to compute and store a Hash value for a row or set of columns and compare between source and target database.....of course you may be unable/unwilling to modify the database structure.

    You mentioned wanting to avoid truncate/reload which I wholeheartedly agree with; I would also advise doing your updates and deletes in a set-based operation rather than using the OLEDB Command Task in SSIS.

    Here are a couple of good articles about incremental data loading:

    http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/62063

    http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/69766

    Regards

    Lempster

  • Hi Lempster,

    Thank you for taking time to respond in detail to my inquiry. I have read through the two articles you've referenced and contemplated the information. The more I think through the situation, I believe doing a cross-database (which would be cross-server as well in my case) query would be best to generate a data source as referenced in the first article. I will do more research to figure out if this is feasible. What I can try in the meantime is do a data source from my web server database and use a lookup transform back to the enterprise database, output the No Match entries, and update the Active flags to 0 for these rows. Slow and somewhat painful, but it may work until I can get authorization to link the servers.

    I am intrigued with the CDC idea and have read about it a bit today. I am a bit concerned with that approach on our enterprise database because the software we use (built by a third party) abusively flogs the databases relentlessly. :w00t: The database may slow down even more if that approach is used in our scenario.

    Thank you again for your time. I will post back what we use for our interim solution.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply