存储过程调用存储过程,变量不能通过?
--存储过程sp_kljcb_cx
CREATE Procedure sp_kljcb_cx
(
@qsrq nvarchar(8),
@zzrq nvarchar(8)
)
AS
--声明变量@qsrq(起始日期),@zzrq(终止日期)
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
--建立临时表#Temp_kljc_flhz
create table #Temp_kljc_flhz(
kl_kcdm varchar(4),
kl_kcmc varchar(40),
kl_spdm varchar(4),
kl_spmc varchar(50),
kl_qcsl numeric(12,4),
kl_drsl numeric(12,4),
kl_zdrsl numeric(12,4),
kl_xssl numeric(12,4),
kl_dhsl numeric(12,4),
kl_dcsl numeric(12,4),
kl_thsl numeric(12,4),
kl_zfcsl numeric(12,4),
kl_jcsl numeric(12,4)
)
set nocount on
declare cursor_kc_ck cursor local
for
select kc_ck.ckdm from kc_ck
open cursor_kc_ck
declare @ckdm varchar(4)
fetch cursor_kc_ck into @ckdm
while @@fetch_status=0
begin
insert into #Temp_kljc_flhz(
kl_kcdm,kl_kcmc,kl_spdm,kl_spmc,kl_qcsl,kl_drsl,kl_zdrsl,kl_xssl,kl_dhsl,kl_dcsl,kl_thsl,kl_zfcsl,kl_jcsl)
exec sp_kljcbnew @qsrq,@zzrq,@ckdm
fetch cursor_kc_ck into @ckdm
end
close cursor_kc_ck
deallocate cursor_kc_ck
select kl_kcdm as 仓库代码,kl_kcmc as 仓库名称,kl_spdm as 商品代码,kl_spmc as 商品名称,kl_qcsl as 期初数量,kl_drsl as 调入数量,kl_zdrsl as 总调入数量,kl_xssl as 销售数量,kl_dhsl as 兑换数量,kl_dcsl as 调出数量,kl_thsl as 退货数量,kl_zfcsl as 总发出数量,kl_jcsl as 结存数量
from #Temp_kljc_flhz
drop table #Temp_kljc_flhz
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
执行建立sp_kljcb_cx过程时候出错,必须声明变量 '@qsrq '。不知道什么原因,请大家帮忙,谢谢了。
[解决办法]
sp_kljcbnew 这个存储过程的问题吧?
[解决办法]
去掉
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO