SSIS VS 2015: What SSIS task should i use to check whether there is any Excel file in a directory?

  • I need in my package to make sure that the destination folder contains no .xlsx files, and then depending on that direct my further flow accordingly.
    SSIS VS 2015: What SSIS task should i use to check whether there is any Excel file in a target directory where my package will write data to?

    Likes to play Chess

  • Personally, rather than using a Script Task and coding manually, I would use a For Each Loop. Then, if you enter the loop, you know that there are files. If you don't, there aren't.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thom A - Sunday, November 25, 2018 3:36 PM

    Personally, rather than using a Script Task and coding manually, I would use a For Each Loop. Then, if you enter the loop, you know that there are files. If you don't, there aren't.

    This is also how I would handle it.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Sounds neat. thanks. and to check whether the loop has been entered i just put a script task into it and assign = 1 to a variable that =0?

    Likes to play Chess

  • VoldemarG - Sunday, November 25, 2018 6:36 PM

    Sounds neat. thanks. and to check whether the loop has been entered i just put a script task into it and assign = 1 to a variable that =0?

    Use an Expression task, not a script task; again, far easier. 🙂

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • VoldemarG - Sunday, November 25, 2018 6:36 PM

    Sounds neat. thanks. and to check whether the loop has been entered i just put a script task into it and assign = 1 to a variable that =0?

    Why do you need to do this?

    If you put a task in the FEL and it executes, the loop has been entered.

    Tasks in the FEL will not execute if the FEL has not been entered. No need for any checks, unless, perhaps, you are doing something additional outside of the loop.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Phil Parkin - Monday, November 26, 2018 5:19 AM

    VoldemarG - Sunday, November 25, 2018 6:36 PM

    Sounds neat. thanks. and to check whether the loop has been entered i just put a script task into it and assign = 1 to a variable that =0?

    Why do you need to do this?

    If you put a task in the FEL and it executes, the loop has been entered.

    Tasks in the FEL will not execute if the FEL has not been entered. No need for any checks, unless, perhaps, you are doing something additional outside of the loop.

    Difference here, Phil, is the OP wants to do something if there are no files, not if there are. The task can't be inside the For Each, as the fact that the Container has been entered means that they don't want to said process. So there needs to be something like an Expression Task in the For each (that changes the value of a boolean variable to True, for example) and then the On Success Flow to the next task (after the For Each Container) will be on success and that the value of said variable is false.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thom A - Monday, November 26, 2018 5:35 AM

    Difference here, Phil, is the OP wants to do something if there are no files, not if there are. The task can't be inside the For Each, as the fact that the Container has been entered means that they don't want to said process. So there needs to be something like an Expression Task in the For each (that changes the value of a boolean variable to True, for example) and then the On Success Flow to the next task (after the For Each Container) will be on success and that the value of said variable is false.

    Yup, it appears I wrote my reply while being less than fully awake!

    As you suggest, it would seem that the best solution is to create a Boolean variable 'HasFiles', default 'false' and to use an expression inside the FEL to set it to 'true'.

    After the FEL, use appropriate 'Expression and Constraint' precedence constraints to direct the flow.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply