sqlserver的游标怎么那么慢啊
ohfox 2010-05-25 03:17:26 我的游标只会搜索出来大概2000行的数据,然后我:
open year_cur
fetch next from year_cur into @stockid,@id,@isYear,@reportyear,@income,@cost,@profit
WHILE @@fetch_status = 0
BEGIN
if isnull(@income,-1)<=0 or isnull(@cost,-1)<=0 or isnull(@profit,-1)<=0
begin
set @score =0
--结果直接进最终的结果表
insert into #tempscore values(@stockid,@score)
--set @notcompute =@notcompute+1;
continue;
end
/*省略N多的处理*/
insert into #temp values(@stockid,0,0,@maolilv)
fetch NEXT from year_cur into @stockid,@id,@isYear,@reportyear,@income,@cost,@profit
END
DEALLOCATE year_cur
这一小段的目的是如果,@income,@cost,@profit有一个是非正的值,我就直接插股票对应的得分为0到临时表#tempscore 里面去,供以后使用。
可是这段sp几乎要跑10分钟!!崩溃了要!!