在存储过程中创建临时表. [英] create temp table in stored procedure.
本文介绍了在存储过程中创建临时表.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个存储过程来从表中获取记录,但出错了.
在下面找到存储过程.
I created one stored procedure to get records from table but in giveing an error.
find stored procedure below.
ALTER procedure getattrecord(
@month int,
@year int
)
as
begin
create table #temp(staffid varchar(10),attstatus char(1))
insert into #temp (select staffid,mrngstatus from demo_tbl where mrngstatus='P' and YEAR(date)=@year and MONTH(date)=@month) union all (select staffid,evngstatus from demo_tbl where evngstatus='P' and YEAR(date)=@year and MONTH(date)=@month)
select staffid,cast(count(*) as float) /2 from #temp group by staffid
end
推荐答案
临时表将声明如下:
Temporary table will be declared as below:
Declare @temp table(
staffid varchar(10),
attstatus char(1)
)
希望这会有所帮助.
Hope this helps.
这篇关于在存储过程中创建临时表.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文