Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
Rob K.
Rob K.
SSC-Enthusiastic
SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)

Group: General Forum Members
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.
Lempster
Lempster
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2683 Visits: 1657
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
Rob K.
Rob K.
SSC-Enthusiastic
SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)

Group: General Forum Members
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. 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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search