How to get a column values in a single Row
I want all 'name's in a single row , selperated by ','
FOR XML PATH ('')
Only from SQL server 2005 +...
select re.col2 ,count(*)
,(
select isnull(rei.name,' ') + ',' AS [text()] from dbo.Mytable rei
WHERE (
(
(re.col2 is NULL)
AND
(rei.col2 is NULL)
)
OR
( re.col2 = rei.col2 )
)
FOR XML PATH ('')
) as names
from dbo.Mytable re
group by re.col2