Execute SQL Task, passing in a single variable, and using ? twice. Issue

  • I am using an "execute SQL Task" with t-sql typed in directly. I pass in a single (date) variable that it used in two t-sql queries, like this:

    select field 1.... from ... where date > ?

    ....

    select field 2.... from ... where date > ?

    When I run the package I get an error message. When I commented out either one of the queres (so "?" is active only once) the execute task ran successfully. Finally I passed in two input variables to the t-sql: Date1 and Date 2, both set to the

    same date. Then the SSIS package ran fine and returned the expected results.

    Originally I thought that passing in a single variable to the t-sql would cause all instances of "?" to be replaced by that value. Please clarify the situation for me.

    TIA,

    Barkingdog

  • I believe that in the Execute SQL Task, the ? are mapped to the variables regarding their ordinal position. Since SSIS can't know if you are using two distinct variables or one variable two times, he will generate an error.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Map it twice, but it is mapped ordinally..

    CEWII

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

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