declare @t table (id int , chr char(1))insert into @tselect 1, 'a' union select 1, 'h' union select 1, 'y' union select 4, 'k' union select 4, 'f' select * from @tselect distinct id, STUFF((select '' + cast(chr as nvarchar(20)) from @t where id= t.id FOR XML PATH('')),1,0,'') from @t t