SSIS

  • 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

  • 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


  • 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

  • Here is an article that has samples about files & folders expresssions

    --Ramesh


  • 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

  • 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


  • 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