下面写sqlserver2000 的存储过程
为什么报错
create PROCEDURE p1
@nian int,@yue int ,@chanpingname varchar(50),
@maoyileixing varchar(50),@qiyemingchen varchar(50),
@bycz float output,@bycl float output,
@ljcz float output,@ljcl float output,
@sntqcz float output,@sntqcl float output
as
declare @_snnf int;
begin
SELECT @bycl=SUM(zongzhong) AS chanliang,
@bycz=SUM(allprice) AS chanzhi
FROM ccmxb
WHERE (tianbaoshijian = @nian+'/'+@yue)
GROUP BY @chanpingname,@maoyileixing,@qiyemingchen;
SELECT @ljcl=SUM(zongzhong) AS chanliang,
@ljcz =SUM(allprice) AS chanzhi
FROM ccmxb
WHERE (tianbaoshijian like @nian)
GROUP BY @chanpingname,@maoyileixing,@qiyemingchen;
set @_snnf=@nian-1;
SELECT @sntqcl=SUM(zongzhong) AS chanliang,
@sntqcz =SUM(allprice) AS chanzhi
FROM ccmxb
WHERE (tianbaoshijian like @_snnf)
GROUP BY @chanpingname,@maoyileixing,@qiyemingchen;
end
------解决方案--------------------------------------------------------
SELECT @bycl=SUM(zongzhong) AS chanliang,
@bycz=SUM(allprice) AS chanzhi
FROM ccmxb
WHERE (tianbaoshijian = @nian+'/'+@yue)
GROUP BY @chanpingname,@maoyileixing,@qiyemingchen;
这样的语句需要拼接成动态的