以下储存过程在SQL7.0上为何不行?(10分)

Y

ymg1103

Unregistered / Unconfirmed
GUEST, unregistred user!
Create Procedure yebbrowse
@cyear Int,
@cmonth Int
AS



--创建临时表
Declare @t Table(
个人账号 Varchar(20) Not Null,
单位缴存 Numeric(18,2),
个人缴存 Numeric(18,2),
转入金额 Numeric(18,2),
支取金额 Numeric(18,2),
利息 Numeric(18,2),
余额 Numeric(18,2),
其中利息总额 Numeric(18,2)
)



Insert Into @t
select 个人账号,SUM(单位缴存) AS 单位缴存,SUM(个人缴存) AS 个人缴存,SUM(转入金额) AS 转入金额,
SUM(支取金额) AS 支取金额,SUM(利息) AS 利息,SUM(余额) AS 余额,SUM(其中利息总额) AS 其中利息总额 FROM
gjj WHERE (年份<=@cyear OR 年份 is null) AND (月份<=@cmonth or 月份 is null) GROUP BY 个人账号



Update @t Set 余额=ISNULL(余额,0)+ISNULL(单位缴存,0)+ISNULL(个人缴存,0)+ISNULL(转入金额,0)-ISNULL(支取金额,0)+ISNULL(利息,0)
Update @t Set 其中利息总额=ISNULL(其中利息总额,0)+ISNULL(利息,0)



Delete from yeb
Insert Into yeb
Select a.部门,a.个人账号,a.姓名,a.单位缴存,a.个人缴存,a.转入金额,a.支取金额,a.利息,b.余额,b.其中利息总额,a.是否封存,a.封存日期 from gjj a
Left Outer Join @t b On a.个人账号=b.个人账号 Where a.年份=@cyear And a.月份=@cmonth
 
好像不认@t
 
在SQL 2000中
--创建临时表如下
Declare @t Table(
个人账号 Varchar(20) Not Null,
单位缴存 Numeric(18,2),
个人缴存 Numeric(18,2),
转入金额 Numeric(18,2),
支取金额 Numeric(18,2),
利息 Numeric(18,2),
余额 Numeric(18,2),
其中利息总额 Numeric(18,2)
)
那在SQL7.0中该如何定义呀?
 
在sql语法中,insert,update,delete中好像不能使用变量作表名的;
我觉得你干脆不要用临时表了,直接生成这张表到数据库作临时数据用,一样使用的呀。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
539
import
I
S
回复
0
查看
823
SUNSTONE的Delphi笔记
S
顶部