ExecSQL outputs multiple updates script to variable

  • EamonSQL

    SSCrazy

    Points: 2287

    Hi,

    I have an ExecSQL task that generates many UPDATE statements which I would like to store as a variable and used in a subsequent ExecSQL statement.

    Is this possible? So far I have tried to store the output as a variable but then it fails.

    Any help welcome on this.

    Thanks,

    Eamon

     

     

     

  • Thom A

    SSC Guru

    Points: 98219

    Do you mean you're generating Dynamic SQL? Where is this variable you are wanting to "store" the dynamic SQL in, SSIS or SQL Server (if the latter, then surely you already have a variable as you're executing dynamic SQL with sp_executesql). If you do want to store the value in SSIS, do these statements return any other datasets?

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • Phil Parkin

    SSC Guru

    Points: 243485

    If you are running some SQL which returns a result set of T-SQL queries, the answer is yes.

    Return the result set to an Object variable, which should be shredded within a Foreach container, which itself would contain an ExecuteSQL task whose command would be set from an Expression, to contain the text from the shredded result set.

    • This reply was modified 1 month, 1 week ago by  Phil Parkin. Reason: Fix typos

    If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

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

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