SSIS: execute first task if condition met else skip to next

后端 未结 7 1943
忘了有多久
忘了有多久 2021-01-11 17:46

I am getting to know SSIS, I apologize if the question is too simple.

I got a set of tasks inside a foreach-loop-container.
T

7条回答
  •  再見小時候
    2021-01-11 17:52

    Hopefully I didn't misunderstand the question but a possible solution can be as written below.

    I created a sample ForEach loop. The loop itself is an item enumerator. It enumerates the numbers 1, 2, 3. The acutal value is stored in a variable called LoopVariable.

    Sample Foreach loop

    Settings of the loop

    Assigning to variable

    There is another variable named FirstShouldRun which is a Boolean variable showing the first task in the foreach loop should be runned or not. I set this variable's EvaluateAsExpression property to true, and its expression is (@[User::LoopVariable] % 2) == 0. I would like to demonstrate with this that every second time the first task should be started.

    Variables

    Setting of the property of the variable

    The two tasks do nothing much but display a MessageBox showing the task has been started.

    I started the package and first and the third time the first task didn't started. In the second loop the MessageBox (showing "First started") appeared.

    After that you should set FirstShouldRun variable as you like.

    As I mentioned in my first comment to the OP, this solution is based on the idea of Amos Wood written in another answer.

提交回复
热议问题