My value for a Variable I load from an SSIS Task Resultset goes to -1

Posted on 2009-04-22
Last Modified: 2013-11-10
I have a simple Select Statement that returns a single row. I am trying to read that value into a Package Level Variable and then use that variable in the next step.

Each time I run the package, I get the value -1 returned. Details of what I am trying to do is as follows:
SQL Statement: Select (Max(LoadNumber) + 1) As LoadNumber From TableName

Variable Name: User::LoadNumber, Datatype Int32

Execute SQL Task Details:
- ResultSet: SingleRow
- ConnectionType: OLEDB
On the Result Set Tab:
- ResultName: LoadNumber
- Variable Name: User::LoadNumber

I have a Script Task after this task to show a Messagebox with the value of the Variable and it shows -1

When I run the statement in a Query window, it shows the correct value.

Does anyone know why I could be getting -1? Seems like some type of returncode to me but I can't find from what?
Question by:QCentric
    LVL 17

    Expert Comment

    What is the SingleRow Result Set datatype set to? LONG?

    Author Comment

    I can't find the property for the SingleRow Result Set dataypte.

    The ForcedExecutionValueType is Int32
    The Value returned in the Select Statement is Int
    The User Variable is Int32

    Accepted Solution

    I decided to change the return value from Int32 to String and I can now read the value fine.

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Join & Write a Comment

    I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
    When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Viewers will learn how the fundamental information of how to create a table.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now