SELECT
TypeName
,(SELECT ','+ UserName FROM [ContainerMembers] t WHERE TypeName= aa.TypeName FOR XML PATH('')) AS Users
FROM [ContainerMembers] aa
GROUP BY [TypeName]
SELECT
TypeName
,(SELECT ','+ UserName FROM [ContainerMembers] t WHERE TypeName= aa.TypeName FOR XML PATH('')) AS Users
FROM [ContainerMembers] aa
GROUP BY [TypeName]