SQL Server Performance

Concat values in a column

Discussion in 'General Developer Questions' started by harsh_sr, Oct 28, 2004.

  1. harsh_sr New Member

    I've a table with following data

    DATA
    -----
    Red
    Blue
    White
    Yellow

    I want to fetch result as 'Red, Blue, White, Yellow' in a single SQL Query.

    How to do that?
    Thanks


    Harsh
  2. FrankKalis Moderator

    What about


    DECLARE @allnotes VARCHAR(8000)
    SELECT
    @allnotes = ISNULL( @allnotes + ', ', '' ) + DATA
    FROM
    < your table >
    SELECT
    @allnotes



    -----------------------
    --Frank
    http://www.insidesql.de
    -----------------------
  3. harsh_sr New Member

    It works...cool
    Thanks a lot Frank

    -Harsh

Share This Page