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

后端 未结 7 1941
忘了有多久
忘了有多久 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 18:07

    That's a bit tricky.

    You have to create a Script Task and check if your variable is not null in there.

    So first you have the script task in which you will have the following code in your Main() function:

    public void Main()
    {
        if (Dts.Variables["User::yourVariable"].Value != null)
        {
            Dts.TaskResult = (int)ScriptResults.Failure;
        }
        else
        {
            Dts.TaskResult = (int)ScriptResults.Success;
        }
    }
    

    Then you create two connections from your script task, one to the task that needs to be executed when your variable is not null, and one to the next task (or to another script, if you need to check again, if the variable is not null).

    Then you right-click on the (green) arrow of your first connection and select "Failure". Right-click the connection to the next task / script and set it to "Completion".

    It should then look something like this:

    example

    That's it.

    0 讨论(0)
提交回复
热议问题