• MMartin1 (12/26/2014)


    Create a table valued function that returns the delimited string as a column in a table. Join whatever table you are working on to this table (valued function) on the key columns.

    Most people don't know how to do that first part with performance in mind. If you can limit it to 8K bytes, here's an article on a fast T-SQL-only solution. If you need more than that, the article also contains a simple SQLCLR solution that Paul White wrote.

    http://www.sqlservercentral.com/articles/Tally+Table/72993/

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