• WITH CTE AS

    (

    SELECT DISTINCT

    Category

    FROM Sampletable

    )

    SELECT Category,

    Organisams = STUFF((

    SELECT ',' + Organisams

    FROM Sampletable

    WHERE Category = CTE.Category

    ORDER BY Organisams

    FOR XML PATH(''),

    TYPE).value('.','varchar(max)'),1,1,'')

    FROM CTE

    ORDER BY Category;

    There is an article related to this method below

    http://www.sqlservercentral.com/articles/comma+separated+list/71700/


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/