莓核美食网
您的当前位置:首页sql存储过程循环while

sql存储过程循环while

来源:莓核美食网


用游标吧

declare @a int,@b int
declare ccc cursor for select * from test where id>@id
open ccc
fetch next from ccc into @a,@b
while (@@fetch_status=0)
begin
.......
end
close ccc
declare ccc(这个操作看看别的系统存储过程怎么写的 记不太清了 每次都是copy的)

大概就是这样 不知道语法有没有错误 最近一段时间没用sqlserver了 看看系统存储过程就能明白怎么用cursor了

显示全文