Variable Expressions


It's sometimes useful to reference a variable that has a value that is the result of an expression. Variables can contain values that you or a task sets, but they can also contain expressions and return the result of the expression instead of their value.

For example, suppose you need to use an expression to generate a folder name, filename, or date in a certain format, and you need to use the same expression in multiple locations in your package. You could copy the expression and paste it into all the locations you need it. But then, if it ever needs to change, you must change it in each of those locations. That's really a headache and just bad practice. It would be nice if you could build the expression in one place and then use it in all the locations throughout the package where you need it. Then, managing the expression would be simple because you would only need to change it in one place.

You can use variable expressions for this. Create the variable with an expression and then you can reference the variable in the other locations through property expressions. If you're familiar with the concept of macros in other languages and applications, this is very similar. For a more detailed discussion of this approach, please see Chapter 22, which demonstrates variable expressions and how to use them in detail.

There are two properties on IS variables related to expressions. The EvaluateAsExpression property is a Boolean that tells the variable to return the results of an expression instead of the value in the variables Value property. The second property related to expressions is the Expression property. This property contains the actual expression to be evaluated. When the EvaluateAsExpression property is set to TRUE, the variable returns the result of the expression whenever you get its value. If EvaluateAsExpression is set to FALSE, the variable simply returns the value in the variable's Value property.



Microsoft SQL Server 2005 Integration Services
Microsoft SQL Server 2005 Integration Services
ISBN: 0672327813
EAN: 2147483647
Year: 2006
Pages: 200
Authors: Kirk Haselden

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