Return Integer value from SSIS execute SQL Task

2019-05-09 11:20发布

问题:

I am using SQL Server 2005 Business Intelligence Studio and struggling with returning an integer value from a very simple execute SQL Task. For a very simple test, I wrote the SQL Statement as:

Select 35 As 'TotalRecords'

Then, I specified ResultSet as

ResultName = TotalRecords and
VariableName = User::TotalRecords

When I execute this, the statement is executed but the variable doesn't have the updated value. However, it has the default value that I specified while variable definition.

The return of a date variable works, but integer variable isn't working. The type of User::TotalRecords specified is Int32 in a package scope.

Thanks for any hints

回答1:

The value for Result Name is incorrect. Try using an ordinal (position) based approach.

A basic set up for an OLE or ADO.NET Execute SQL Task

Here I have specified the ordinal of 0 for the zeroeth column in my resultset.

Here you can see the original variables and their values (-1, -2) as well as their run-time values of 35 for both.



回答2:

Once your package completes yuor variables go back to their default state. If you use a breakpoint or a msgbox, you'll see that during execution your variable does have the value.