Use parameters with Execute SQL task

  • That's actually a better approach. It's simpler and like Jamie says, always works. It even works for cases where the DAC wouldn't normally allow parameters like for table names and column names etc.

     

  • Well, for the chapter example I was working on, using parameters was less messy than a dynamic statement. I also wanted to use an output parameter. Believe me, I tried a bunch of different approaches. I think it all depends on the problem you are trying to solve. 

    Aunt Kathi Data Platform MVP
    Author of Expert T-SQL Window Functions
    Simple-Talk Editor

  • Ah, output parameters...

    Well, now, that's a different story altogether, isn't it. Eh hem...

    K

  • Sorry to say but the book has a lot of bugs with regards to the output parameters. SSIS seems to be extremely difficult for setting output parameters. I'm running into issues where the data type for a variable and data types for parameter mappings are different and i receive errors about how they are not set properly. Extremely irritating when all I'm trying to do is set a variable to an integer.

    select max(id) from table. I'd like to set a variable to that as an output parameter.

    THoughts?

  • Please try to do the following - in parameter mapping replace "?" with "0". I did it like that with OLE DB data source and worked.  

    Select ProductID, ProductName

    from Production.Product

    Where ProductID = ?

    The Parameter mapping page looks like this:

    User:roductID, Input, Long, 0

     

     

     

  • Its Awesome. Working for me in SQL SERVER 2008 R2

Viewing 6 posts - 16 through 20 (of 20 total)

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