Before I give myself some sort of stress related heart attack.
Would anyone know how to complete the seemingly simply task of setting the result set of one data flo
Starting with SSIS 2012, you can easily assign a variable a value using the Expression Task. There is no need to writing a Script -- which most of us are wary of, for accomplishing a seemingly simple task of setting a variable's value.
Ex: If I have a date variable called Today
and I want to assign it a value, I can do so easily in the Expression task as shown below.
Further Reading: MSDN - SSIS Expression Task Documentation.
NOTE: (The accepted answer is outdated.)
You can use a Data Flow Script component to transfer a data flow column value to an SSIS variable. However, you must follow certain rules when working with the Data Flow Script component and SSIS variables.
SSIS doesn't allow you to assign values to SSIS variables in the script procedure that processes rows. But there are pre- and post-execute procedures where you can handle the assignment.
In your Script component, add the SSIS variable to the ReadWriteVariables property. Edit the script and declare a variable in the ScriptMain class. Use the PreExecute procedure to initialize the variable. Use the ProcessInputRow procedure to assign the input -buffer column value to the script variable. And, use the PostExecute task to assign the value from the script variable to the SSIS variable.
Here's an example VB script component. It has an SSIS variable (MyOutVariable) that will get the output of the script variable (MyVar). The MyVar variable gets it's value from the MyNumber column in the data flow.
Public Class ScriptMain
Inherits UserComponent
Dim MyVar As Integer
Public Overrides Sub PreExecute()
MyBase.PreExecute()
'initialize variable local to data flow
MyVar = 0
End Sub
Public Overrides Sub PostExecute()
MyBase.PostExecute()
' output variable value to SSIS variable
Me.Variables.MyOutVariable = MyVar
End Sub
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
' logic to get value
MyVar = Row.MyNumber
End Sub
End Class