SELECT
ID,
Names = (stuff (( SELECT ',' + Name FROM Table a where a.ID=b.ID
FOR XML path ( '' ) ),1,1,''))
FROM
Table b group by Id
SELECT
ID,
Names = (stuff (( SELECT ',' + Name FROM Table a where a.ID=b.ID
FOR XML path ( '' ) ),1,1,''))
FROM
Table b group by Id