Passing the result of a sql command to a variable

  • Greetings all,

    So I am having a very frustrating problem with a fairly simple task in SSIS that for all intents and purposes should be working but unfortunately it is not.

    I have a variable in SSIS call Data1 that is a string type. I then have an execute sql task that attempts to assign a value to this which is actually a sql select statement stored in a table within a database...so for example;

    select script from scripttable where id = 1

    script is the column that contains the sql that needs to load into the variable. So for instance the result would be; select * from dbo.table

    But I get a failure stating "An error occurred while assigning a value to variable "Data1" the type of value being assigned to variable "user::Data1" differs from the current variable type.

    Which I call BS for several reasons;

    1) The variable is a string, the result set is from a column that is varchar(1000)

    2) If I just paste the output of that query into the variable (so copying the column from the table that contains the script) in the SSIS package it works fine

    is there something I am not doing right? I do this all the time to assign folder paths with no issues...

    Link to my blog http://notyelf.com/

  • In your Execute SQL Script task, what do you have the ResultSet property set to? It should be set to Single Row.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Yes that is correct. And for some strange reason it just started working! I am not sure exactly what I did to get it to run other than I put some single quotes as the default value for the variable and ran it...but even now when I take those out it still runs fine....very strange.

    Link to my blog http://notyelf.com/

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

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