在这个存储过程中怎样使用临时表?

CREATE PROCEDURE Calc(@Supp varchar(8000)) AS

exec ('select no,color,sum(qty_in) as qty_in into #tmpd
from cSup_Out
where supp_no in ('+@supp+')
group by no,color')
--在为条件的需要,只能用exec(' ')来执行.

select * from #tmpd where 条件
--在执行上一行时提示找不到表 #tmpd

CREATE PROCEDURE Calc(@Supp varchar(8000)) AS

exec ('select no,color,sum(qty_in) as qty_in into #tmpd
from cSup_Out
where supp_no in ('+@supp+')
group by no,color;
select * from #tmpd')

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus