Is it possible to create an SSIS package that can be passed a file (through a variable) and from the variable determine which Data Flow Task to use?
What I would like to be able to do is to create a single DTSX package that can take in a filename as a variable and detect (simply from the filename) if it is an Excel 2003, Excel 2007 or CSV file and from that, execute the correct Data Flow Task. I will then process the results in another single Data Flow Task after the data has been imported.
I used SSIS a long time ago and I am just coming back to using it so my knowledge is locked away and will come back slowly. I just can't seem to remember (or find on Google) a way of creating a conditional split in the Control Flow.
Any ideas?
As HLGEM has indicated, as long as the internal structure was consistent, something like this would suffice.
I'd declared a package level variable, DatFlowSelector
and within my initial script task, I'd use logic to determine what path the flow should take based on the FileName
variable you were going to use.
After wiring up the expected outputs, use the Precedence Constraint editor to determine what path evaluates to true. My logic was simply @[User::DataFlowSelector] == N
where N maps to the value my script assigned.
I generally switch the ShowAnnotation
property to "ConstraintOptions" when I modify the constraints as it makes it immediately clear to future maintainers that there is something going on. SQL 2012 will help in this case as it assigns the fx
glyph to the connector but displaying the logic can provide at-a-glance confirmation of sound logic.
I did something similar with a for each loop in the control flow. It went through all the files in the processing directory and directed them to the correct dataflow based on the name of the file (since they were all the same file type but with different internal structures).