Assuming That your column name is NAME
And table name is MYTABLE
you can use the Following query:
DECLARE @strTemp VARCHAR(MAX)
SET @strTemp = ''
SELECT @strTemp = @strTemp + ISNULL(NAME,'') + ','
FROM MYTABLE
--Remove last comma
SET @strTemp = SUBSTRING(@strTemp ,1,LEN(@strTemp ) -1)
--Get Result
SELECT @strTemp
You can filter null records using the following
SELECT @strTemp = @strTemp + NAME + ','
FROM MYTABLE
WHERE NAME IS NOT NULL