zoukankan      html  css  js  c++  java
  • sql之游标


    --select * from   master..sysprocesses
    use test
    declare my_cursor cursor scroll dynamic --scroll表示可以向前或向后移动   dynamic:表示可写也可读,
    for
    select F3 from temp --定义my_cursor 游标

    open my_cursor --打开游标
    declare @name nvarchar(128) --定义一个变量
    fetch next from my_cursor into @name --游标停在第一条记录前面,第一次执行,测试有没有记录存在
    while(@@fetch_status=0) --取数据,直到-2即没有记录
    begin
    print '姓名: ' + @name 
    --fetch next from my_cursor
    fetch next from my_cursor into @name
    end

    --fetch first from my_cursor into @name
    print @name
     --update temp set F9='zzg' where current of my_cursor 
    /* delete from 个人资料 where current of my_cursor */
    close my_cursor
    deallocate my_cursor

  • 相关阅读:
    python-杂烩
    24 Python 对象进阶
    23 Python 面向对象
    22 Python 模块与包
    21 Python 异常处理
    20 Python 常用模块
    18 Python 模块引入
    2 Python 基本语法
    1 Python 环境搭建
    3 Python os 文件和目录
  • 原文地址:https://www.cnblogs.com/nickflyrong/p/4759517.html
Copyright © 2011-2022 走看看