In sql 2017 puoi utilizzare la funzione STRING_AGG:
SELECT STRING_AGG(T.val, ',') AS val
, T.grp
FROM @tbl AS T
GROUP BY T.grp
In sql 2017 puoi utilizzare la funzione STRING_AGG:
SELECT STRING_AGG(T.val, ',') AS val
, T.grp
FROM @tbl AS T
GROUP BY T.grp