Di sql 2017 Anda dapat menggunakan fungsi STRING_AGG:
SELECT STRING_AGG(T.val, ',') AS val
, T.grp
FROM @tbl AS T
GROUP BY T.grp
Di sql 2017 Anda dapat menggunakan fungsi STRING_AGG:
SELECT STRING_AGG(T.val, ',') AS val
, T.grp
FROM @tbl AS T
GROUP BY T.grp