游标SQL Cursor 基本用法
http://www.cnblogs.com/Gavinzhao/archive/2010/07/14/1777644.html
1 table1结构如下
2 id int
3 name varchar(50)
4
5 declare @id int
6 declare @name varchar(50)
7 declare cursor1 cursor for --定义游标cursor1
8 select * from table1 --使用游标的对象(跟据需要填入select文)
9 open cursor1 --打开游标
10
11 fetch next from cursor1 into @id,@name --将游标向下移1行,获取的数据放入之前定义的变量@id,@name中
12
13 while @@fetch_status=0 --判断是否成功获取数据
14 begin
15 update table1 set name=name+'1'
16 where id=@id --进行相应处理(跟据需要填入SQL文)
17
18 fetch next from cursor1 into @id,@name --将游标向下移1行
19 end
20
21 close cursor1 --关闭游标
22 deallocate cursor1
游标SQL Cursor 基本用法的更多相关文章
- SQL Cursor 基本用法
1 table1结构如下 2 id int 3 name varchar(50) 4 5 declare @id int 6 declare @name varchar(50) ...
- sql Cursor的用法
table1结构如下 id int name ) declare @id int ) declare cursor1 cursor for --定义游标cursor1 select * from ta ...
- SQL Cursor 基本用法[用两次FETCH NEXT FROM INTO语句?]
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ...
- SQL 游标 Cursor 基本用法
/* table1结构如下 id int name varchar(50) */ declare @id int ) declare cursor1 cursor for --定义游标cursor1 ...
- Oracle中Cursor的用法
关键字 概念 类型 异常处理 一 概念 游标是SQL的一个内存工作区,由系统或用户以变量的形式定义.游标的作用就是用于临时存储从数据库中提取的数据块.在某些情况下,需要把数据从存放在磁 盘的表中 ...
- SQL Server游标 C# DataTable.Select() 筛选数据 什么是SQL游标? SQL Server数据类型转换方法 LinQ是什么? SQL Server 分页方法汇总
SQL Server游标 转载自:http://www.cnblogs.com/knowledgesea/p/3699851.html. 什么是游标 结果集,结果集就是select查询之后返回的所 ...
- SQL 中ROLLUP 用法
SQL 中ROLLUP 用法 ROLLUP 运算符生成的结果集类似于 CUBE 运算符生成的结果集. 下面是 CUBE 和 ROLLUP 之间的具体区别: CUBE 生成的结果集显示了所选列中值的所有 ...
- 三、存储过程(Stored Procedure)与游标(Cursor)
一.存储过程 一组为了完成特定功能的SQL语句集,经编译后存储在数据库中,用户通过指定存储过程的名字并给出参数,来执行它. 在大型数据库中,存储过程和触发器具有重要的作用.无论是存储过程还是触发器,都 ...
- 二.数据库游标对象cursor与实例
1.数据库游标对象cursor 2.select实例 代码展示: import pymysql conn=pymysql.connect( host='192.168.199.249', port=3 ...
随机推荐
- SNF开发平台WinForm之十五-时间轴控件使用-SNF快速开发平台3.3-Spring.Net.Framework
一.显示效果如下: 二.在控件库里选择UCTimeAxis 拖拽到窗体里. 三.加入以下代码,在load事件里进行调用就可以运行了. #region 给时间轴控件加载数据 private void U ...
- android源码 键盘消息处理机制
键盘消息处理模型: .WMS统一管理Window, 它包含了InputManager变量,其对应c++层的NativeInputManager2.c++层的NativeInputManager包含 i ...
- pandas DataFrame applymap()函数
pandas DataFrame的 applymap() 函数可以对DataFrame里的每个值进行处理,然后返回一个新的DataFrame: import pandas as pd df = pd. ...
- [Big Data - Codis] Codis集群的搭建与使用
一.简介 Codis是一个分布式的Redis解决方案,对于上层的应用来说,连接Codis Proxy和连接原生的Redis Server没有明显的区别(不支持的命令列表),上层应用可以像使用单机的Re ...
- zookeeper频繁异常问题分析
Reference: https://blog.csdn.net/xjping0794/article/details/77784171 1.1 操作系统信息1.1.1 ...
- 2. Attention Is All You Need(Transformer)算法原理解析
1. 语言模型 2. Attention Is All You Need(Transformer)算法原理解析 3. ELMo算法原理解析 4. OpenAI GPT算法原理解析 5. BERT算法原 ...
- Mac xcode 配置OpenGL
配置过程 安装homebrew 打开命令行 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/ ...
- hdoj:2022
#include <iostream> #include <string> using namespace std; int main() { int m, n; int x, ...
- Intelij U
1.https://link.jianshu.com/?t=http://idea.lanyus.com/,下载JetbrainsCrack-2.6.2.jar,放到bin目录 2.编辑bin目录下面 ...
- 关于ECMP 等价路由
1.ECMP简介 Equal-CostMultipathRouting,等价多路径.即存在多条到达同一个目的地址的相同开销的路径.当设备支持等价路由时,发往该目的 IP 或者目的网段的三层转发流量就可 ...