Let’s say you have 5 rows in a table. Column1 is populated for 4 out of the 5 rows with the following data:
599
abc
xyz
456
The following SQL will provide the results as such:
599, abc, xyz, 456
declare @YourString varchar(4000)
select @YourString = isnull(@YourString + ‘, ‘, ”) + cast(column1 as varchar(20))
from some_table
where guid = @SomeGUID
group by column1
select @YourString