• Lynn Pettis (1/25/2013)


    Sean Lange (1/25/2013)


    Lynn Pettis (1/25/2013)


    Sean,

    @BatchID should have been @BranchID in the sp_executesql statement. That was a type.

    Regarding @params = @params, quite legal. From MSDN (emphasis is mine, and yes the names can be the same):

    sp_executesql [ @stmt = ] statement

    [

    { , [ @params = ] N'@parameter_name data_type [ OUT | OUTPUT ][ ,...n ]' }

    { , [ @param1 = ] 'value1' [ ,...n ] }

    ]

    Lynn,

    I figured the Branch/Batch was a typo. After I posted I realized it was pretty much a direct copy from what you posted (typo included). The @params = @params looked so strange to me I just assumed it wouldn't work.

    The worst part of this is that not catching the typo is a clear indication that the OP does not have a good grasp of what is going on here. :w00t:

    OP - you need to truly understand the code here before you use it. You are the one who has to support it when you get that call at 3am. I don't think your boss will be too impressed if you tell them you don't understand the code because you used what some person on the internet suggested.

    Actually the OP did catch the typo regarding @BatchID/@BranchID.

    Good grief!!! I wish it was morning so I could blame lack of coffee...I will blame it on the anticipation of getting a few beers after work today (being Friday).

    /me creeps backwards from this one before I make even more of a fool out of myself. 😀

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/