I have a 'Execute SQL task' which product a row count. see screen 1.
I am trying to print 'ContactRowCount' in ssis 'Script task'. See screen 2.
But Dts.Variables["User::ContactRowCount"] is null. I can retrieve it. Anyone knows how to retrieve variable value from 'Execute SQL task' in script task
Screen - 1
Screen - 2
Do read documentation, all of this has been covered.
Variables
I have two variables. One is for my SQL, called
Quqery
, which is optional. The other is an Int32 calledRowCount
.Execute SQL Task
I have an Execute SQL task that uses an OLE DB Connection Manager. I have specified that it as a
ResultSet
of Single Row. I use myQuery
variable as the source.The value is
In the Result Set tab, I map the
0
ResultSet to my variableUser::RowCount
.If you are using a different Connection Manager provider (ADO.NET or ODBC), then these semantics all change. But it's documented.
Script Task
I ensure that I am passing in my variable as a read only object
Within my script, I need to access that variable. This is case sensitive. Furthermore, I want the
.Value
property. Your code, were it to work, would be casting the SSIS Variable to a string. This results in the default of the object emitting its nameMicrosoft.SqlServer.Dts.Runtime.Variable
Instead, we will want to access the .Value property which is returned as an object. If you were trying to do something mathematical with this value, then you'd need to convert it to an integer value but since we're going to string, that's easy.
use variable name in the script task and not the result set name.