neat one dystarry. And here's the solution for rows grouped by type_id:
declare @type_id int
declare cursor1 CURSOR FAST_FORWARD FOR SELECT distinct type_id FROM fruit
drop table #Temp
create table #Temp (region_id int, atext varchar(100))
open cursor1
fetch next from cursor1 into @type_id
while @@fetch_status = 0
begin
print @type_id
insert into #Temp (region_id, atext)
select distinct @type_id,
STUFF((SELECT ', ' + name FROM dbo.fruit where type_id = @type_id FOR XML PATH('')), 1, 2, '')
from fruit
--group by region_id
fetch next from cursor1 into @type_id
end
close cursor1
deallocate cursor1
select * from #Temp