ExecSQL outputs multiple updates script to variable

  • 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

     

     

     

  • 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.
    Larnu.uk

  • 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 5 years, 5 months ago by  Phil Parkin. Reason: Fix typos

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

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

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