Sql-server – SSIS script task – Execute Dataflow task based on variable value

sql serverssis

I have been trying to create a package which executes a couple of dataflow tasks based on the available value in one of the variables. How can I achieve this?

The sample scenario: Variable param may have a string value "current" or "previous". If the user selects current then the data flow task A will get executed, else data flow task B will get executed.

I have two variables : 1) Param and 2) ParamValue. Using the script task If param=="current" then paramvalue would be 1, else if param=="previous" then paramvalue would be "Previous"

And in the precedence constraint added conditions to execute the data flow tasks. But its not working as expected.

Best Answer

Precedence constraints should be able to handle this requirement. Obviously without seeing the package and how you're setting up the constraints, we can't tell you why it isn't working. However, I've found that using an Expression for the Disable property of the data flow task can also be a good way to control flow. Maybe that will work better for you.

To do this, right-click on the data flow task and select Properties. Go to Expressions and click the ellipsis (...) to open the Property Expressions Editor. Under Property, select Disable, and under Expression, click the ellipsis again to open the Expression Builder. Then write the expression that determines if the data flow task should be disabled or not.