views:

2949

answers:

3

I have a SSIS package, which depending on a boolean variable, should either go to a Script Task or an Email task.(Note: the paths are coming from a Script Task)

I recall in the old dts designer there was a way to do this via code. What is the proper way to accomplish this in SSIS?

A: 

A Conditional Split task does what you want. Add the Conditional Split task, add in an additional output (a default output is provided), and set up the Condition for that output. Then just tie the outputs (default and new) to the Script and Email tasks as appropriate.

Harper Shelby
Unfortunately, the Conditional Split Task is under Data Flow. The two available paths are coming from a Script Task. I probably should have been more specific.
D.S.
+5  A: 

Isn't a Conditional Split a data flow task, which takes a row of data and pushes it in one of two directions according to some property of the data???

Oops, that is correct. I found this blog entry which explains how to do proper control flow conditional branching based on boolean values.

Harper Shelby
Thanks, it looks like this will do what I need!
D.S.
+2  A: 

In control flow, drag the green arrow to the email task, then right-click on it and you will see you can set it from 'Completed' to 'Conditional', then you can set an expression on the condition. The arrow will then turn blue. You should then be able to drag another arrow to the other script, and set that to conditional.

I have this set-up often, many times you want to email if a certain condition applies. The standard syntax for the conditional constraints is something like:

@[User::SendEmail] == True

Assuming your SendEmail variable is a boolean. If you use anything else, just construct an expression that evaluates to either true or false.

Remember to set the conditionals to OR instead of AND, otherwise it won't complete unless it can take both routes!

Meff