views:

36

answers:

1

SSIS

Hello.

Firstly excuse me if this doesn’t make a lot of sense as I’m fairly (as in 2 days ago) new to SSIS.

Ultimately I’m looking to import all data from an XML file and depending on what kind of file it is process in a different way and load to a set of relational tables in a Microsoft SQL Server 2008.

Each XML file has a Boolean flag of 0 or 1. Depending on if its 0 or 1 I would like the data flow to go a different way as each type of file needs to be processed differently.

I’ve been looking at using the conditional split transformation however I’ve come across a couple of issues.

I get the data using a dataflow XML source and check the flag then depending on if its 0 or 1 the data flows left or right. However the XML contains lots of data and I can only move the data element with the flag and I need it to move the rest of the data in that direction as well.

I thought I might open the file check the flag, store the flag as a variable then close the file and open a 0 package or a 1 package depending on the variable which would then open the xml file again and pull out the data. However this doesn’t “smell” right as I’m opening and closing the same XML file twice.

Has anyone else come across this and how did they get around it?

+1  A: 

Although I don't think anything wrong with opening a file twice in an ETL operation, you can achieve your goal with a single data flow task that includes a conditional split component which uses a variable (or derived column etc) for condition expression. Setting the variable can be easily implemented in data flow task by using a script component.

orka
Hello. Orka, many thanks for the response. Just to reiterate, my XML file contains say 50 separate elements. Now I can use the XML source to Conditional Split to evaluate the result of one element (the flag) and then load that one element into its relevant table. How ever what I need is to evaluate that element and then process the other 49 elements based on that flag. Do you think I need to look at using sequence container as well?
FairFunk
You can easily achieve your goal by using sequential container but if you don't want to open same file twice then you can read first element and set the flag in a script component at the data flow task. Then you should use that flag in the conditional split. If you go to sequential container way then you can check the flag at the first element and then decide which data flow task to run. Hope this help.
orka

related questions