SSIS - Bulk Update at Database Field Level

Posted by Adam on Stack Overflow See other posts from Stack Overflow or by Adam
Published on 2010-03-17T15:28:24Z Indexed on 2010/03/17 15:31 UTC
Read the original article Hit count: 305

Filed under:
|
|

Hello,

Here's our mission:

  • Receive files from clients. Each file contains anywhere from 1 to 1,000,000 records.
  • Records are loaded to a staging area and business-rule validation is applied.
  • Valid records are then pumped into an OLTP database in a batch fashion, with the following rules:
    • If record does not exist (we have a key, so this isn't an issue), create it.
    • If record exists, optionally update each database field. The decision is made based on one of 3 factors...I don't believe it's important what those factors are.

Our main problem is finding an efficient method of optionally updating the data at a field level. This is applicable across ~12 different database tables, with anywhere from 10 to 150 fields in each table (original DB design leaves much to be desired, but it is what it is).

Our first attempt has been to introduce a table that mirrors the staging environment (1 field in staging for each system field) and contains a masking flag. The value of the masking flag represents the 3 factors.

We've then put an UPDATE similar to...

UPDATE OLTPTable1 SET Field1 = CASE WHEN Mask.Field1 = 0 THEN Staging.Field1 WHEN Mask.Field1 = 1 THEN COALESCE( Staging.Field1 , OLTPTable1.Field1 ) WHEN Mask.Field1 = 2 THEN COALESCE( OLTPTable1.Field1 , Staging.Field1 ) ...

As you can imagine, the performance is rather horrendous.

Has anyone tackled a similar requirement?

We're a MS shop using a Windows Service to launch SSIS packages that handle the data processing. Unfortunately, we're pretty much novices at this stuff.

© Stack Overflow or respective owner

Related posts about ssis

Related posts about bulk