OK, I'm no SSIS expert, but I am trying to do something very simple which I just cant get to work.
It seems there are lots of posts about this issue but I am doing the same as all the posts suggest, without success.
I will make this as simple as possible in order to demonstrate the issue.
1. Create a new SSIS Package and save it as TestPackage.
2. Right click on the canvas of the "Control Flow" tab and click "Variables".
3. Create a new variable from the "Variables" window and callit "varInt". Scope will default to the package name (i.e. "TestPackage"), DataType=Int32, Value = 0, ReadOnly=False.
4. Add a "Script Task" to the Control Flow tab.
5. Edit the Script Task and set the "ReadWriteVariables" value to "varInt".
6. Click on "DesignScript" and add the following code.
Dts.Variables("varInt").Value = 2
Dts.TaskResult = Dts.Results.Success
7. Save the above, then Execute the "Script Task".
The result I get is the first message box display "0", the second message box display "2". As expected.
If I execute the script again, unless I am missing something fundamental, I would expect the first message box to now show "2", then the second box to show "2". However, it shows me the "0" followed by the "2" again.
I therefore assume that whilst the value of the variable is being changed successfully whilst inside the ScriptTask, the new value is not be saved upon completion of the ScriptTask. The new value assigned to the variable "varInt" will therefore not be available to other tasks in the package which is the ultimate aim here.
How do I therefore update the value of a variable from a Script Task so that the new value of the variable is available to other task which will access the variable.
Any help would be appreciated as I have Googled this death.