SELECT substring(list, 1, len(list) - 1)
FROM (SELECT list =
(SELECT DISTINCT name + ','
FROM sys.objects
ORDER BY name + ','
FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)')) AS T
Yes, somewhat unwieldy and not fully intuitive. On the other hand, this is guaranteed to work as intended, which is not true for "SELECT @x = @x + col".
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]