当前位置: 代码迷 >> Sql Server >> 一个关于游标的小疑点
  详细解决方案

一个关于游标的小疑点

热度:68   发布时间:2016-04-27 11:53:48.0
一个关于游标的小问题
open cstucou
--打开游标
fetch next from cstucou into @stuno
[email protected],当小于剩余名额时(@不<=@limitnum-@choosenum)继续分配
set @i=1
while @@fetch_status=0 and @i<=@limitnum-@choosenum
begin
update stucou set state='选中'where current of cstucou
set @[email protected]+1fetch next from cstucou into @couno
end
红色的语句是什么意思?

------解决方案--------------------
[email protected]
循环.如果成功 并且 @I<....条件成立
更新表的state为选中。条件是当前游标的读取的值
[email protected]
------解决方案--------------------
[email protected],当小于剩余名额时(@不<=@limitnum-@choosenum)继续分配
说的很明白了。
------解决方案--------------------
探讨

[email protected][email protected]+1在这里用有点模糊,是计数的意思?引用:
open cstucou
--打开游标
fetch next from cstucou into @stuno
[email protected],当小于剩余名额时(@不<=@limitnum-@choosenum)继续分配
set @i=1
while @@fetch_status=0 and @i<[email protected]
  相关解决方案