select n.*,columnname=stuff((select ','+m.fname from (select a.id,b.id as bid ,a.fname from s_projectdata a , (select operationtype,id from som_ent_enterprise) b where charindex(convert(varchar(10),a.id),b.operationtype) > 0 and parentid = '2') m where m.bid=n.id for xml path('')), 1, 1, '') from som_ent_enterprise n