• markpringle (4/19/2015)


    It uses a Temp table, but temp tables can't be used in functions, right? I am just not SQL savvy enough to know how to repurpose it.

    I see nothing of a temp table in the code. It's just a standard practice for folks like Eirikur and many others to add "USE TempDB" to code to ensure that we cause no damage to a real database whether we use any DDL or not. It's just a habit on forums.

    --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)