SSIS - Variable expression vs Expression Task

Question:

In SSIS 2012, I'm confused about the difference between the Expression Task and a Variable's "Expression" property. What's the difference? I want to set a variable, @Now, to the equivalent of the T-SQL GETDATE() function. I assume the only difference is the Expression Task only sets the variable value once, while the variable's Expression property is executed every time the variable is accessed. Thus, the Expression property for the current date and time would change every time the variable is used.
Answer:

There are many task that can be achieved in both methods, but assume that you have to change a variable value after a specific task or at a specific condition (that can be related to other tasks) (when a task succeed, set a variable value equal to 1), in this case expression property cannot achieve your goal so you have to use expression task.
Also, in your case, assume that you want to set @Now variable to GETDATE() inside a for-each loop container (on each loop), so the variable expression property may not work (it will be set once at the package execution), you need an expression task.

Popular posts from this blog

SSIS - Script Task error: Exception has been thrown by the target of an invocation.

Don’t install Hadoop on Windows!

SSIS - script component DateTime Formats Implicit Conversion