Ik hoop dat dit helpt. U kunt reageren ORDER BY T1.Str_Value
indien niet nodig en stel de nvarchar(500)-grootte in zoals vereist
SELECT DISTINCT T1.UserId,
Stuff(
(SELECT N', ' + T2.Str_Value
FROM t T2
WHERE T2.userId = T1.userid
ORDER BY T2.Str_Value
FOR XML PATH(''),TYPE).value('text()[1]','nvarchar(500)'),1,2,N'')
AS Str_Value
FROM t T1