March 30, 2009 at 1:37 am
Hi I need a help in SSIS.
Issue: I have a folder that contains the files .xls and .csv , these files need to import to a table using single SSIS package.
The way I'm thinking is we can use ForEachLoop,that will give the file name , from which we can get the extension of the file.Now based on the extension we need to choose the DataFlow task (coz for .xls the source will be Excel Source and for .csv the source will be Flat File source).
But I'm not sure how to choose the DataFlow task if we are getting the file name. Using Read Write variable? but how?
If anyone knows please help.
Thanks in advance
Mithun
Thanks & Regards,
MC
March 30, 2009 at 4:54 am
Assuming that you have two DataFlow tasks and you just wanted to direct the execution conditionally to these two tasks, you just have set the "Precedence Constraint" of "Workflow" to either "Expression" or "Expression Or Constraint" and then write the expression as "@FileExtension == "csv"" to transfer the flow to CSV DataFlow Task and respectively do the same for the EXCEL DataFlow task as well.
--Ramesh
March 30, 2009 at 7:42 am
Thanks Ramesh,
So here how can I get the file extension to that variable? (this may be simple, but I'm just a beginner in SSIS 🙂 )
Regards,
Mithun
Thanks & Regards,
MC
March 30, 2009 at 9:15 am
Here is an article that has samples about files & folders expresssions
--Ramesh
March 30, 2009 at 11:00 am
Thanks Ramesh,
Let me know whether the steps Im folowing is correct or not,
1.In ControllFlow tab get the ForechLoop item
2.Set the Package level variable to the file location
3.In the expression get the extension of the file
If the abow steps re correct what I'm thinking is now within the ForechLoop get two DataFlow task , and then based on the extension select one among them.
Is it fine if Im giveing the Check @FileName == csv or @FileName = xls in the Expression part of each of the DataFlow Task?
regards,
Mithun C
Thanks & Regards,
MC
March 30, 2009 at 11:15 pm
Basically, you need 1 ForEachLoop File Enumerator, 2 Variables (one to hold fully qualified name and the other one to hold file extension) and 2 DataFlow Tasks with conditional workflows/precendences.
Then in the precedence constraint, you will have an Expression like @FileExtension == "csv" for CSV DataFlow & @FileExtension == "xls" for EXCEL DataFlow.
--Ramesh
March 31, 2009 at 2:34 am
Thank you verymuch Ramesh.
I will try this...
Thanks & Regards,
Mithun C
Thanks & Regards,
MC
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply