存储过程中的游标
遇到这样的情况,可以如何优化存储过程.
这些存储过程其实并不复杂.如
declare c1 for
select a,b
from tb1
open ..
fetch into...
while @@FETCH_STATUS=0
begin
select @a=c from tb2 where f1=a and f2=b
select @b=d from tb2 where f3=a and f4=b
...
insert into ##tb3(fa,fb)
values(@a,@b)
Fetch c1 into ...
end
close c1
deallocate c1
一般的结构就这样,只是中间取其它数时的字段更多而已.
但可能由于中间的计算比较多,涉及比较多的计算公式.然后把结果插入到另一个临时表.

