• Fewer steps and converts nulls to blanks if you want them (take out the ISNULL operator if you don't want null values). You can also easily make the delimiter a defined variable.

    --Create a test table

    CREATE TABLE dbo.Test (testval VARCHAR(10))

    GO

    --Insert values for testing

    INSERT INTO dbo.Test (testval) VALUES ('T1')

    INSERT INTO dbo.Test (testval) VALUES ('T2')

    INSERT INTO dbo.Test (testval) VALUES (NULL)

    INSERT INTO dbo.Test (testval) VALUES ('T3')

    GO

    DECLARE @i NVARCHAR(MAX)

    SELECT @i = COALESCE(@i + ',','') + CAST((ISNULL(testval,'')) AS NVARCHAR(MAX))

    FROM dbo.Test

    SELECT @i