Home Forums SQL Server 7,2000 T-SQL Csv list in column to separate columns RE: Csv list in column to separate columns

  • Eliza (9/18/2012)


    Jeff Moden (9/17/2012)


    Eliza (9/17/2012)


    Hi all,

    Can I ask please if I have a row and one column has a csv list in it. Is there a way please to split the csv list into columns in a row?

    For example if I have

    1 - Apple, Pear, Orange

    2. - Pear, Apple, Bananna

    In my output I would like

    Col1. Col2. Col3

    1 Apple__Pear____Orange.

    2 Pear___Apple___Bananna

    Sorry underscores are meant to split the columns.

    Thank you

    Eliza

    Are the number of elements in each CSV fixed or variable with in the same column?

    The number can vary, however it will be between 0 (null value) and a maximum of 25. It won't go higher than 25.

    Are you all set with this or do you still need some help?

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