• Luis Cazares (2/20/2014)


    sqldba20 (2/20/2014)


    Nevermind...I was able to figure out using the link posted by Luis. Came with this SQL and it works.

    How on earth did you figure that out from the link I posted? :hehe:

    This method might kill the performance as it will create more rows than needed.

    Baffled me too, Luis.

    rCTE's aren't the best choice for this - slower than FOR XML PATH, waaaaay overcomplicated.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden