本文介绍了当我执行存储过程显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的商店程序如下
My Store Procedure as follows
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[Presea_Intakerpts]
as
begin
set nocount on
declare @BatchID varchar(20), @MajorName varchar(100), @Minorcode varchar(10), @Intake_Capacity int,
@BatchStartdate varchar(15), @BatchEnddate varchar(15)
Create table #TempTable (MajorName varchar(100), Minorcode varchar(10), BatchStartdate varchar(15), BatchEnddate varchar(15),
Intake_Capacity varchar(5))
Declare Batch_details_Cur Cursor for
select cbm.cbm_batch_id, Course_Name = (select top 1 ltrim(cmn_Minor_desc) from co_minor_master where cmn_minor_Code = cbm.cmn_minor_code), cbm.cmn_minor_Code,
Intake_Capacity = (select top 1 cbn_batch_nos from co_batch_number where cbm_batch_id=cbm.cbm_batch_id),
convert(char(12), cbm.cbm_batch_start_dt,106) as BatchStartdate, convert(char(12),cbm.cbm_batch_end_dt,106) as BatchEnddate, ltrim(cbm.Cbm_Batch_start_time)
from co_batch_master cbm where cbm.cbm_active <> 'D' and datepart(year,cbm_batch_start_dt) <> '3000'
and datepart(year,cbm_batch_start_dt) <> '4000' and datepart(year,cbm_batch_start_dt) <> '5000' and datepart(year,cbm_batch_start_dt) <> '6000'
and cbm.cmj_major_code = 'pstf'
and ((cbm_batch_start_dt between '03/03/2014' and '03/15/2014') or
(cbm_batch_end_dt between '03/03/2014' and '03/15/2014'))
order by cbm.cmn_minor_Code, cbm.cbm_batch_start_dt
Open Batch_details_Cur
fetch next from Batch_details_Cur into @BatchID, @MajorName, @Minorcode, @Intake_Capacity, @BatchStartdate, @BatchEnddate
while @@Fetch_status = 0
begin
print @Intake_Capacity
insert into #TempTable values(@MajorName,@Minorcode,@BatchStartdate,@BatchEnddate,@Intake_Capacity)
fetch next from Batch_details_Cur into @BatchID, @MajorName, @Minorcode, @Intake_Capacity, @BatchStartdate, @BatchEnddate
end
close Batch_details_Cur
Deallocate Batch_details_Cur
select * from #TempTable
end
$ b当我跑步时,$ b
e存储过程显示错误如下
when i run the store procedure shows error as follows
exec [Presea_Intakerpts]
Cursorfetch: The number of variables declared in the INTO list must match that of selected columns.
我上面的商店程序有什么错误。
问候,
narasiman P.
what is the mistake in my above store procedure.
regards,
narasiman P.
推荐答案
这篇关于当我执行存储过程显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!