将列【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


  

posted @ 2012-11-06 10:53  Leis  阅读(181)  评论(0编辑  收藏  举报