begin transaction
declare mycursor Cursor for
select stu_no,score,words from belind_console where college_id=@college_id
for update of score
open mycursor
while(0=0)
begin
fetch next
from mycursor
into @stu_no,@hhg,@words
if @@fetch_status<>0
break
else
begin
--do someting
end
end
close mycursor
deallocate mycursor
博客展示了一段SQL代码,包含事务开始、游标声明、打开游标、循环获取数据等操作。代码从指定表中选取学生编号、分数和备注信息,使用游标遍历结果集,若获取状态异常则跳出循环。
864





