Precedence Constraints


Precedence constraints direct the tasks to execute in a given order. They direct the workflow of your SSIS package based on given conditions. Precedence constraints have been enhanced dramatically in SQL Server 2005 Integration Services conditional branching of your workflow based on conditions.

Constraint Value

Constraint values are the type of precedence constraint that you may be familiar with in SQL Server 2000. There are three types of constraint values:

  • Success: A task that's chained to another task with this constraint will execute only if the prior task completes successfully.

  • Completion: A task that's chained to another task with this constraint will execute if the prior task completes. Whether the prior task succeeds or fails is inconsequential.

  • Failure: A task that's chained to another task with this constraint will execute only if the prior task fails to complete. This type of constraint is usually used to notify an operator of a failed event or write bad records to an exception queue.

Conditional Expressions

The nicest improvement to precedence constraints in SSIS 2005 is the ability to dynamically follow workflow paths based on certain conditions being met. These conditions use the new conditional expressions to drive the workflow. An expression allows you to evaluate whether certain conditions have been met before the task is executed and the path followed. The constraint evaluates only the success or failure of the previous task to determine whether the next step will be executed. The SSIS developer can set the conditions by using evaluation operators. Once you create a precedence constraint, you can set the EvalOp property to any one of the following options:

  • Constraint: This is the default setting and specifies that only the constraint will be followed in the workflow.

  • Expression: This option gives you the ability to write an expression (much like VB.NET) that allows you to control the workflow based on conditions that you specify.

  • ExpressionAndConstraint: Specifies that both the expression and the constraint must be met before proceeding.

  • ExpressionOrConstraint: Specifies that either the expression or the constraint can be met before proceeding.

An example workflow can be seen in Figure 1-6. This package first copies files using the File System task, and if that is successful and meets certain criteria in the expression, it will transform the files using the Data Flow task. If the first step fails, then a message will be sent to the user by using the Send Mail task. You can also see the small fx icon above the Data Flow task. This is graphically showing the developer that this task will not execute unless an expression has also been met and the previous step has successfully completed. The expression can check anything, such as looking at a checksum, before running the Data Flow task.

image from book
Figure 1-6



Professional SQL Server 2005 Integration Services
Wireless Java : Developing with Java 2, Micro Edition
ISBN: 189311550X
EAN: 2147483647
Year: 2006
Pages: 182

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net