游标循环所带来的问题,真不知如何是好,请各位大侠指教!谢谢!

我省略了变量的声明和其中程序的执行,只列出循环的代码,谢谢各位高手指教,谢谢!谢谢!
我有两个表:consultant 其中有字段consultantno 是主键
duty 其中有字段consultantno,salarydate 是主
键,consultantno 都在consultant表中的consultantno范
围内

create procedure salary_temp (@salarydate char(7))
as
begin
--变量定义

set @j=0
set @i=0
--取得工资参数
select @paysalary=paysalary,@taxpoint=taxpoint,@overhead=overhead,@overhead1=overhead1
from salaryconsts

--循环所有的促销顾问
declare consultant_cur cursor for select consultantno from consultant_accountinfo order by consultantno
open consultant_cur
fetch next from consultant_cur into @consultantno
while @@fetch_status=0
begin

select @typescode=typescode from duty where salarydate like @sarydate and consultantno like @consultantno

if @typescode is null or @typescode = ''
begin
set @j=@j+1
fetch next from consultant_cur into @consultantno
continue
end
--以下有代码是执行工资算法的
.
.
__以下是执行工资算法的

set @i=@i+1

fetch next from consultant_cur into @consultantno
end
close consultant_cur
deallocate consultant_cur
select @i as 'i',@j as 'j'
end

exec salary_temp '2002/04'
结果是:i=3316 j=80 总共有3396人
但是我单独执行语句
select * from duty where salarydate like @sarydate 的话结果却是1132行,为什么呢,请各位大侠指教,不胜感激!!谢谢!!

[1474 byte] By [Leony-老树] at [2007-12-13]