• Jason-299789 (10/3/2012)


    Karthick,

    Jeff was making valid point about about how to create the Tally table in the first place, most people will write a while loop, or a recursive CTE rather than using a cross join between two of the sys tables in the db.

    I suspect Jeff wants to see the developer do the cross join rather than the CTE or a While loop. 😀

    Or a cascading cross-joined CTE Itzik Ben-Gan style. Or a SELECT from a Tally table.

    Bonus points if the Developer says, "It Depends" and then demonstrates and explains all 3 without further prompting. Even more points for the tangent of using IDENTITY vs ISNULL(ROW_NUMBER()) on the creation of a physical Tally Table.

    If you know this stuff, you should be able to talk about it spontaneously including some pros and cons. If you've only memorized it, you might only come up with the cross join and offer no extra information without me having to ask a thousand questions to find out what you know.

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