SQL Server SSIS variables in the use of expressions, you can not change the value of the

In SQL Server SSIS, we can define as initial values ​​of variables and expressions, in fact, SSIS variable is defined as the expression we can not change the value of a variable, we do the following experiment:

 

First we define a variable of type String called Message in SSIS package, we define an initial value for the variable "Hello Tom" (note that at this time we have no Message is defined as a variable expression), as follows:

Then we SSIS package, using a "Script Task" component, which is set for the variable Message "ReadWriteVariables" variable, that variable Message in "Script Task" component can be given a new value:

In the "Script Task" assembly, we use C # code, change the value of the variable Message "Hello Jack", C # code is "Script Task" component is as follows:

Then we run the SSIS package, after the "Script Task" component set a breakpoint to see the value of the variable Message, we can see that when the SSIS package runs out of "Script Task" component, the value of the variable Message changed to "Hello Jack ",As follows:

Now we will set the value of the variable Message to the expression "Hello Tom", as follows:

Run the SSIS package again, when after running "Script Task" component, we can see the value of the variable Message has not changed, the value is still set for the expression "Hello Tom", as follows:

This shows that SQL Server SSIS variables in expressions if used as its initial value, the value of the variable in SSIS package can not be changed, this feature if the developer did not notice, it is likely to cause the program the Bug, so we should pay attention to this feature SSIS variable.

 

Guess you like

Origin www.cnblogs.com/OpenCoder/p/11234671.html