首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

列装行后怎么将结果放入一个表里

2012-03-03 
列装行后如何将结果放入一个表里请教大侠们一个问题,像列装行的写法select Ltyp,stuff((select ,+Lname

列装行后如何将结果放入一个表里
请教大侠们一个问题,像列装行的写法
select Ltyp,stuff((select ','+Lname from #SQltemp b where a.Ltyp=b.Ltyp order by Lname for xml path('')),1,1,'')
from #SQltemp a
group by Ltyp



如何把得到的结果,如何存入另一个表里

[解决办法]

SQL code
 insert into 另表  select Ltyp,  stuff((select ','+Lname from #SQltemp b where a.Ltyp=b.Ltyp order by Lname for xml path('')),1,1,'') from #SQltemp a group by Ltyp
[解决办法]
SQL code
insert into tbselect Ltyp,stuff((select ','+Lname from #SQltemp b where a.Ltyp=b.Ltyp order by Lname for xml path('')),1,1,'')from #SQltemp agroup by Ltyp--orselect Ltyp,stuff((select ','+Lname from #SQltemp b where a.Ltyp=b.Ltyp order by Lname for xml path('')),1,1,'')    into tbfrom #SQltemp agroup by Ltyp 

热点排行