Consider a table,
Id columnA
1 a
2 b
3 c
Select ColumnA from table gives the result as below,
columnA
a
b
c
Is it possible to get
ColumnA
a,b,c
Consider a table,
Id columnA
1 a
2 b
3 c
Select ColumnA from table gives the result as below,
columnA
a
b
c
Is it possible to get
ColumnA
a,b,c
heres an article describing how to do it with a stored procedure which internally uses a loop to do the concatenation.
One way is the XML PATH trick
SELECT
SUBSTRING(
(
SELECT
',' + columnA
FROM
myTable
FOR XML PATH ('')
)
, 2, 7999)
FROM
foo