Conditional statement in a control flow

  • To preface, I am a newbie to SSIS. I would like to do the following but can not figure out how, any help would be appreciated.

    I want to read multiple XML source files through a foreach loop. First looking to see if one field in the file exists and if so going to a data flow task and if it does not exists moving the file through File System Task and going to the next file.

    I am aware of the conditional split data flow but how do I do a conditional statement in the control flow?

    Thanks in advance.

  • Hi Michael,

    You can use the variable expressions within the precedents constraints. You can store the results you want to check into a variable and then use this variable in an expression like (@varName == true) within the precedents constraints which then splits the flow to the tasks of your choice.

    see msdn online : http://msdn.microsoft.com/en-us/library/ms140153(SQL.90).aspx

  • Thank You.

    Can I set a variable within the data flow task after a conditional split without using a script component (not sure how to write the code to do that)?

    I was going to use XML source to a conditional split and then I want to set a variable to true or false based on the split. What is the easiest way to do that, w/o script code? Or if I need to use script code can you tell what it would be to just set a variable to true or false?

    Thanks

  • Assume that you have a Boolean variable called Test. Here is how you would set it to True using a Script Task.

    1) Create a Script Task.

    2) Add 'User::Test' (no quotes) to the ReadWriteVariables property.

    3) Modify the definition of Public Sub Main as follows:

    Public Sub Main()

    Dts.Variables("Test").Value = True

    Dts.TaskResult = Dts.Results.Success

    End Sub

    (Leave the rest of the Script Task code untouched.)

    Job done.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Thank You!

Viewing 5 posts - 1 through 4 (of 4 total)

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