• inHouseDBA (3/29/2015)


    Gurus,

    Thank you very much for your help.

    Is there a way you can explain the interaction of

    WITH T(N) AS (SELECT N FROM ( VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL)) AS X(N))

    with the rest of the solution.

    It just creates 10 rows and it doesn't actually matter what those rows contain except that they should be short for performance reasons. The NULL doesn't really mean anything here. It could be 1s, 0s, anything. All it's doing is building "the presence of rows" that will be used in cross joins to build more rows instead of using a much slower loop or much slower recursive CTE.

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