• One other thing that will help a bit. There's no need for the explicit transaction in the SP_GetNextValue sproc. It's just a waste of clock cycles because of the single UPDATE statement in the proc which will form its own transaction. Since the proc only has one statement in it, there's no real need for SET XACT_ABORT in the proc.

    I'd also remove the BEGIN/END. A lot of other database engines require such a thing in stored procedures but it's not required in SQL Server. If someone asks about the code being more portable, remind them that the type of UPDATE that is being used is essential for helping prevent deadlocks on this high usage proc and its underlying table and that I can guarantee that form of UPDATE isn't portable to most other engines except for Sybase.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)