with fruit as ( select 'Apple' as name, 101 as id UNION ALL select 'Banana' as name, 102 as id UNION ALL select 'Orange' as name, 103 as id UNION ALL select 'Melon' as name, 104 as id UNION ALL select 'Grape' as name, 105 as id )SELECT STUFF((select ','+name from fruit order by id for xml path('')),1,1,'') AS CSV