zoukankan      html  css  js  c++  java
  • 游标使用模板

    select * from #temp order by viid--测试,查看临时表有什么数据,对应的列名是什么

    DECLARE E1cursor cursor       /* 声明游标,默认为FORWARD_ONLY游标 */
    FOR select viid from #temp order by viid
    OPEN E1cursor                 /* 打开游标 */
    declare @gid int ;
    declare @gid2 int ;
    FETCH NEXT from E1cursor into @gid /* 在循环体内将读取下一行数据,第一次运行读取第一行*/
    WHILE @@FETCH_STATUS = 0      /* 用WHILE循环控制游标活动 */
    BEGIN
        select @gid2=count1 from #temp where viid=@gid
        UPDATE [VotingInfo] SET [number] = @gid2 WHERE id=@gid
        FETCH NEXT from E1cursor into @gid  /* 在循环体内将读取下一行数据,第一次运行读取第一行*/
    END
    CLOSE E1cursor                /* 关闭游标 */
    DEALLOCATE E1cursor           /* 删除游标 */
  • 相关阅读:
    Python函数
    linux—shell 脚本编程
    python 内建函数
    列表解析式(List Comprehension)
    python标准库(datetime)
    python字典(dict)
    常用数据结构
    C 2010年笔试题
    C 2012年笔试题(保)
    C 2012年笔试题
  • 原文地址:https://www.cnblogs.com/wyxy2005/p/1776248.html
Copyright © 2011-2022 走看看