Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SSIS - Deactivate Records in Destination not Contained in Results from Source Expand / Collapse
Author
Message
Posted Tuesday, December 17, 2013 12:28 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, May 15, 2014 9:01 AM
Points: 191, Visits: 199
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.
Post #1523847
Posted Wednesday, December 18, 2013 8:31 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, December 19, 2014 9:48 AM
Points: 2,128, Visits: 1,488
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
Post #1524175
Posted Wednesday, December 18, 2013 2:38 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, May 15, 2014 9:01 AM
Points: 191, Visits: 199
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. 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.

Post #1524364
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse