--- use functionCREATE FUNCTION getItem
 (@fid nvarchar(15))  
RETURNS nvarchar(500) AS  
BEGIN declare @all nvarchar(500)
set @all=''
select @all=@all+ contactInfo
 + '' from Utable where fid=@fid
set @all=left(len(@all)-1) 
return @all
END---thenselect [name],dbo.getitem([name]) as contactinfo1 from 
(select distinct [name] from Utable) as A