I have an SSIS Package that is scheduled to export data on a daily basis. I have a few Tasks that I’d like to execute only on the first day of the month. It is important that these Tasks are skipped, and that the Package continue to execute if it is not the first of the month.
After doing a bit of searching, I’ve found numerous references to solve this problem by using the method posted in the following blog post:
http://bi-polar23.blogspot.com/2007/05/conditional-task-execution.html
I think, however, there is a simpler solution. Why can’t I just add an expression to each of my 1st-day-of-the-month Tasks which checks the day of the month and sets the “Disabled” property on the Task accordingly?
Using expressions and disabling the Task seems a lot simpler than adding a dummy script before each Task. Does anyone else see or know of a problem with my method for solving this problem? Preliminary tests appear to work, however, I’ve found SSIS to be finicky. I’d rather not do something that is “unconventional” if it might cause problems in the future.
Thanks for any thoughts.
I don’t think there is anything
unconventionalabout setting expressions to disable tasks on conditional basis. I have done the same thing in a package that I developed. I would prefer to set the conditions directly on theDisableproperty on the task usingExpressionsrather than usingScript Task. Refer screenshot #1. In other words, I agree with your approach.A note of caution with this approach would be that the next person looking into the package may not be aware why a particular task didn’t execute on a given date (in your case first day of the month). To prevent that, you can add an
Annotationstating that there is anExpressionset on theDisableproperty of the task.One other thing I would suggest is to calculate the first day of the month value and store it in a variable that has the property
EvaluateAsExpressionset to true and use this variable in the Expressions of a given task to disable\enable it. This would prevent calculating the value in each of the tasks’ expressions. Screenshot #1 displays that theDisableproperty is set to assume the value stored in the variableIsFirstDayOfMonth. Expression on this variable can be set to calculate the first day of the month.Hope that helps.
Screenshot #1: