游标使用

DECLARE mCursor cursor       /* 声明游标,默认为FORWARD_ONLY游标 */
FOR 
  select BH,Score from Student     /* 打开游标 */
open mCursor
FETCH NEXT from mCursor      /* 读取第1行数据*/
WHILE @@FETCH_STATUS = 0      /* 用WHILE循环控制游标活动 */
BEGIN         

  
  FETCH NEXT from mCursor    /* 在循环体内将读取其余行数据 */
END 

CLOSE mCursor                /* 关闭游标 */
DEALLOCATE mCursor           /* 删除游标 */
原文地址:https://www.cnblogs.com/panjun/p/2226099.html