Technical Article

Comma seperated list - another approach

,

This will make a comma seperated list from a column using 2 select statements.

-- test using pubs database
USE PUBS
GO

-- return csv
declare @value varchar(8000)
set @value = '"'
select @value = @value + emp_id + '", "' from employee
select substring(@value, 1, len(@value) -3) as csv

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating