Create table #test ([id] varchar(20),[name] varchar(50))
Insert #test select 'id01', 'abc'
union all select 'id01' ,'cde'
union all select 'id01', 'f'
union all select 'id02' ,'ef'
union all select 'id02' ,'g'
union all select 'id03' ,'h'
select distinct(id), stuff((select ' ; '+ltrim(name) from #test
where id=b.id for xml path('')),1,1,'') from #test b
drop table #test
Insert #test select 'id01', 'abc'
union all select 'id01' ,'cde'
union all select 'id01', 'f'
union all select 'id02' ,'ef'
union all select 'id02' ,'g'
union all select 'id03' ,'h'
select distinct(id), stuff((select ' ; '+ltrim(name) from #test
where id=b.id for xml path('')),1,1,'') from #test b
drop table #test

