I have aluded as to the use of SSIS property expressions quite a few times on this blog. Regular readers will know what I think of them by now - they're a great mechanism for dynamically modifying the behaviour of your SSIS package at runtime. In short, property expressions ROCK!
Something that I haven't mentioned before but that is very very similar is the ability to evaluate a variable as an expression. This is an alternative to just using your variables as a store of data at runtime - evaluating as an expression means that your variables can be dynamic in exactly the same way that task properties can be.
Recently a question was posed on a newsgroup that got me thinking about this some more. In short the poster was building an SSIS package to load a file. The filename contained a date in the form "MMDDYYYY.xls" and he wanted to have an SSIS variable to contain the name of the file to be loaded - that being a file containing today's date. He thought that package configurations were the key to solving this - not so!
The way to do this is to set 2 properties of the variable as follows:
- EvaluateAsExpression=TRUE
- Expression = RIGHT("0" + (DT_STR, 2, 1252) MONTH( GETDATE() ),
2) + RIGHT("0" + (DT_STR, 2, 1252) DAY( GETDATE() ), 2) + (DT_STR, 4,
1252) YEAR( GETDATE() ) + ".xls"
Each time the variable gets referenced the expression is evaluated. Hence, if the package were run today the variable would return the value 03192005.xls, tomorrow it would be 03202005.xls and so on... he could then reference this variable wherever he wanted to in his package and be safe in the knowledge that he was always referring to the correct file.
See, easy! Evaluating expressions for a variable is valuable way to introduce dynamic values into your package. Explore what they can be used for because they're very powerful ( as are property BLOCKED EXPRESSION and could save alot of work in the long term.
-Jamie