日期:2014-05-19  浏览次数:20482 次

如何在执行存储过程中生成新表
在执行存储过程exec   sel-all时会生成一个表,我如何来再对这个表进行操作呢
我的存储过程如下:
CREATE   proc   sel_all   as
select   l_no,type= '领料单 ',date,danhao,dept,glno,wlbh,l_name,quality,sysdate   from   linliao
union
select   t_id,type= '退料单 ',t_date,danhao,dept,orderno,wlbh,t_name,store sysdate   from   tuiliao

我还需要对其执行后生成的表进行操作,或者让其执行后生成一个新表

------解决方案--------------------
insert into newtable select * from(
select l_no,type= '领料单 ',date,danhao,dept,glno,wlbh,l_name,quality,sysdate from linliao
union
select t_id,type= '退料单 ',t_date,danhao,dept,orderno,wlbh,t_name,store sysdate from tuiliao)a
------解决方案--------------------
select * into table1 from (select l_no,type= '领料单 ',date,danhao,dept,glno,wlbh,l_name,quality,sysdate from linliao
union
select t_id,type= '退料单 ',t_date,danhao,dept,orderno,wlbh,t_name,store sysdate from tuiliao) t

------解决方案--------------------
#临时表名

表名前+ '# '在该连接结束后就自动回收