• JJ B (2/3/2011)


    JJ B. If you're not currently using a loop or the method in the article, what are you using?

    I'll tell ya, but you have to be kind (not that you wouldn't be). I put this together several years ago. I didn't have access to rank functions at the time, and I made this up myself. Also, this is run once a night on very few records (less than 50). So, stressing about being terribly efficient didn't make sense.

    It is a multi-step stored proc. The proc does use what you call a tally table, but not in the same, most likely more efficient way, as you did. Below are comments copied from my code. If they don't make sense and you are still interested, I could attach the proc - which has more comments and actual SQL. 🙂

    No need for the code, JJ B. It's nice to see someone comment correctly! I always tell the folks I work with, "You can tell if you've commented properly by removing all of the code. If you could rebuild the code from the comments, then you've commented correctly." Well done.

    It's ironic... your Step C) is all that needed to be done and it would be the same as this "SQL Spackle" article. Thanks for sharing what you did.

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