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


SSIS - Input Excel file - updating Table - conditional split?


SSIS - Input Excel file - updating Table - conditional split?

Author
Message
debbiekitzke
debbiekitzke
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 9
Hi - I am SUPER new to SSIS , kind of thrown into it with no training or help other that what I can dig up on Google - so I am hoping one of you can walk me thru this.

I have a multi-tabbed Excel file as input - where tab 1 has
action ---- reasonID ---- description
New ---- 1 ---- add new record
Update ---- 2 ---- chg descr of record 2
Delete ---- 3 ---- remove record 3 entirely

I figured out how to create a Conditional split based on the action. and to create a Recordset of the result ( I think)

my problem is - I now have 3 output record sets in my data flow tab.
When I am back in the Control flow -- how do I update the ExceptionReason table with the data from each reason set? besides each one having different recordset names, they will need to perform a different set of SQL ( Insert, Update or Delete)
Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16447 Visits: 13202
Using the conditional split is a good start.
Route the insert rows to an OLE DB Destination and write them directly into the destination talbe (make sure to use the fast load option).

Write the deletes and updates to a staging table or a temporary table (if you want to use a temp table, let me know, it requires additional explanation).
In the control flow, use an Execute SQL Task to update/delete your destination table using the following SQL:


-- deletes
DELETE FROM MyTable
FROM MyTable m
INNER JOIN MyStagingTable s ON m.ID = s.ID
WHERE s.ReasonID = 3;

-- updates
UPDATE m
SET col1 = s.col1
,col2 = s.col2
...
,coln = s.coln
FROM MyTable m
INNER JOIN MyStagingTable s ON m.ID = s.ID
WHERE s.ReasonID = 2;





How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
debbiekitzke
debbiekitzke
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 9
thanks for the response.

Yes I am going to have to use a temp table as our DBA area frowns upon lots of "staging" tables in the database.
Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16447 Visits: 13202
debbiekitzke (9/13/2013)
thanks for the response.

Yes I am going to have to use a temp table as our DBA area frowns upon lots of "staging" tables in the database.


If you have to choose between staging tables or excessive locking and logging by the SSIS OLE DB command, I'd choose staging tables any day.
(tell that to your DBA Smile

Temp tables are a viable alternative, but they can put an extra burden on tempdb, so I hope your DBA has put it on a fast disk.
If you want to use them, you need to make sure they are created before they are used in the data flow. You also need to put the data flow to DelayValidation equals true.
Finally, to make sure the temp table still exists before the data flow actually uses it, you need to put the property RetainSameConnection to true on the connection manager.



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
RonKyle
RonKyle
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1266 Visits: 3341
Tell your DBA to consider putting the staging tables into their own schema. I call mine "Temp", but "Staging" or "Landing" would be good names. This might remove his objections. There is no good reason to object to this in principle. If he's trying to prevent have hundreds of seldom used tables, that might be a practical objection. But he's making things harder for you, probably unnecessarily so.



Richard Warr
Richard Warr
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2578 Visits: 1983
Koen Verbeeck (9/15/2013)

Finally, to make sure the temp table still exists before the data flow actually uses it, you need to put the property RetainSameConnection to true on the connection manager.


And remember to use "Global Temp" tables (the ones that begin with ##).

_____________________________________________________________________
MCSA SQL Server 2012
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