SSIS has a number of debugging tools. The one I could not find myself was a tool to trace variable values at runtime. A quick search on the internet did wonders.
It is often useful to know which value a variable gets while the package runs. This simple little script, which you put in a script task, does the job. So you do not need to know anything about programming. First create a script task. Put it somewhere at the end of your Control Flow.
Then type in the script below:
{geshi xml:lang=“vbnet” lines=“false”}
Public Sub Main()
Dim variableName As String = “User::VandaagDatumID”
Dim vars As Variables = Nothing
Dts.VariableDispenser.LockForRead(variableName)
Dts.VariableDispenser.GetVariables(vars)
Dim variableValue As String = CType(vars(variableName).Value, String)
vars.Unlock()
Dts.Events.FireInformation(-1, “Test Script”, String.Format( _
“The value for VandaagDatumID variable {0} is ‘{1}’”, variableName, variableValue), _
String.Empty, -1, False)
Dts.TaskResult = Dts.Results.Success
End Sub{/geshi}
{highslide type=“img” url=“artikelen/ssis/script_variable_find/script_createscript.jpg” width=600 captionText=‘Visual Basic Script’}{/highslide}
Do change the name of the variable (VandaagDatumID). If you then run the ETL package, you will see the value of the variable in the output window.
{highslide type=“img” url=“artikelen/ssis/script_variable_find/script_outputwindow.jpg” width=600 captionText=‘Output Windows SSIS’}{/highslide}
Frequently asked questions
How do I see the value of a variable while an SSIS package runs?
Put a Script Task at the end of your Control Flow. The script reads the variable and writes the value to the output window with Dts.Events.FireInformation when you run the package.
Where do I see the output of FireInformation in SSIS?
In the SSIS output window, after you run the ETL package. It shows the text with the name and value of the variable.
Do I need to know how to program to trace a variable in SSIS?
No. You paste the short Visual Basic script into a Script Task. You only change the name of the variable, such as User::VandaagDatumID.
How do I read a variable in an SSIS Script Task?
With Dts.VariableDispenser.LockForRead and GetVariables. Then you read the Value of the variable, release the lock with vars.Unlock() and write the value out with FireInformation.
Which debugging tool does SSIS lack by default?
SSIS has debugging tools, but no tool to trace the value of variables at runtime. A Script Task with a few lines of code solves this.
Comments
Related blogs
Using a variable in an OLE-DB Source (SSIS)
Excel connectors and 64-bit
A tool to help you find KPIs