将列【1,2,3】转换为【类别1,类别2,类别3】

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


  

原文地址:https://www.cnblogs.com/leis/p/2756559.html