Setting a package variable from a SQL task

  • Hi

     

    I've run a bit of SQL which returns a value of an integer, one single row.  It is an integer rowset.  I have set this to go into a package variable, but it only ever returns a value of -1 rather then the number that should be returned.  Originally I wanted to return a string, but it kept telling me this was the wrong data type when I tried to return it to the variable unless I set it as an object.  It claims the SQL is runing fine, and when I test it I get the required result, but I have a feeling that the -1 means it is not getting the result set it should.

     

    James

  • What makes you say it is always -1? Remember, SSIS during runtime, will not update the variables pane to reflect the new value of the variable. For this you need to use the watch window in SSIS.

    If you result set is a varchar, you need to map your variable (a string variable) and set the mapping to be Varchar. it will work.

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • Thanks for that.  I'm very new to 2005, and have no experience with SSIS.  I'm not sure how you get the watch window to display variables, so I included a script step which gives me a mesagebox which returns the variable value, and I've been using that to check.  Ive double tested it by changing anohter variable within the script and returning that which is changed.

     

    How do I map a variable to a string?

     

    Thanks

     

    James

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply