To get comma separated list of values of single field in SQL Server

Visit: https://zonixsoft.com (our official Website)

A solution to get comma separated list of values of single field of a database table

 

You can use the following code to get the comma separated list of values of a single field of a table:

 

DECLARE @commaSeparatedVal AS VARCHAR(4000)

SELECT @commaSeparatedVal = ISNULL(@commaSeparatedVal +‘,’,) + CONVERT(VARCHAR,[SKU]) FROM PRODUCT

PRINT @commaSeparatedVal

 


Bookmark and Share