I have the following code which will create a comma delimited list for my results:
DECLARE @listStr VARCHAR(MAX) SELECT @listStr = COALESCE(@listStr+\', \' ,
this works in sql server 2016
USE AdventureWorks GO DECLARE @listStr VARCHAR(MAX) SELECT @listStr = COALESCE(@listStr+',' ,'') + Name FROM Production.Product SELECT @listStr GO