Query : How to fetch comma separted column values
Comma separated column values without using any function.
Problem
To get comma separated all column values of any table
Solution
declare @idString varchar(max)
set @idString = ''
select @idString = @idString + ',' + cast(< column > as varchar) from < table Name >
print @idString
Usage
It's very handy if need to return all related id's in a string.Typically these comma separated Ids goes into 'In' command. i.e. select < column list > from tablename where id in(< comma separated ids >)