Concatenate using distinct


Please login or register to vote for this query.

(click on this box to dismiss)


Q&A for community managers, administrators, and moderators

-- Change the value of UserId below
-- to avoid fetching a cached result set

DECLARE @UserId int = ##UserId##

select distinct C1.object_id,
       stuff((select ','
              from sys.all_columns as C2
              where C1.object_id = C2.object_id
              for xml path(''),  type).value('.', 'nvarchar(max)'), 1, 1, '')
from sys.all_columns as C1

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results