ALTER proc [dbo].[common_proc_temp2]

as
begin
declare @id varchar(50);
declare @cbcontractid varchar(50);
declare @xh int ;
declare owner_03_cursor cursor scroll
for select id from cb_contract where canton_id like '20%'
--2.打开游标
open owner_03_cursor
fetch next from owner_03_cursor into @cbcontractid --into的变量数量必须与游标查询结果集的列数相同
while @@fetch_status=0 --提取成功,进行下一条数据的提取操作
begin
set @xh=1
declare owner_04_cursor cursor scroll
for select id from cb_contract_change where f_cbcontractid=@cbcontractid order by bgrq asc
open owner_04_cursor
fetch next from owner_04_cursor into @id
while @@fetch_status=0
begin
update cb_contract_change set xh=@xh where id=@id
set @xh=@xh+1;
fetch next from owner_04_cursor into @id
end
close owner_04_cursor;
deallocate owner_04_cursor;

fetch next from owner_03_cursor into @cbcontractid --移动游标
end
close owner_03_cursor;
deallocate owner_03_cursor;
end;

sqlserver存取过程游标的更多相关文章

  1. sqlserver存取过程-游标

    ALTER proc [dbo].[common_proc_temp2] as  begin declare @id varchar(50); declare @cbcontractid varcha ...

  2. SQLServer之ISO游标使用

    什么是游标 结果集,结果集就是select查询之后返回的所有行数据的集合. 游标则是处理结果集的一种机制吧,它可以定位到结果集中的某一行,多数据进行读写,也可以移动游标定位到你所需要的行中进行操作数据 ...

  3. sqlserver创建,调用 带返回值存取过程

    <1>create: ALTER  proc [dbo].[common_proc] @sql1 varchar(5000), @sql2 varchar(5000) OUTPUT as ...

  4. SqlServer和MySQL游标学习

    一 sqlserver游标使用 /*** 游标的使用  讲了这个多游标的优点,现在我们就亲自来揭开游标的神秘的面纱.  使用游标的顺序: 声名游标.打开游标.读取数据.关闭游标.删除游标. 1.3.1 ...

  5. SqlServer基础:游标

    记录下今天用到的游标: DECLARE @TempID INTDECLARE @Number INTSET @Number=1DECLARE myCursor CURSOR FOR     SELEC ...

  6. sqlserver 表循环-游标、表变量、临时表

    SQL Server遍历表的几种方法 阅读目录 使用游标 使用表变量 使用临时表 在数据库开发过程中,我们经常会碰到要遍历数据表的情形,一提到遍历表,我们第一印象可能就想到使用游标,使用游标虽然直观易 ...

  7. sqlserver 存储过程返回游标的处理

    创建表: create table tb1( id int , name ) ) ------------------------------------------------- 创建返回游标的存储 ...

  8. Eclipse连接sqlserver体验过程

    以前装的sqlserver 2008试用期到了,就按照网上的步骤,彻底删除了sqlserver,然后又重新装了下,再用eclipse连接的时候,发现提示TCP/IP被禁用,然后找到了sqlserver ...

  9. SqlServer高级特性--游标

    游标 用途:在数据很多的时候,如果在java代码中进行循环之后再进行更新数据,会造成频繁的连接数据库,耗费性能,所以就可以使用到游标 作用:查询出来的集合直接在SQL中进行遍历在进行更新 DECLAR ...

随机推荐

  1. jquery 监听所有锚点链接实现平滑移动

    jquery 监听所有锚点链接实现平滑移动,地址栏上不会改变链接地址 //监听所有锚点链接实现平滑移动 $('a[href*=#],area[href*=#]').click(function() { ...

  2. linux 网卡启动方法

    CentOS 7默认的网卡名称是eno16777736 一般人的是 eth0 编辑配置文件 vi /etc/sysconfig/network-scripts/ifcfg-eno16777736把 O ...

  3. android中Json的一些应用

    JSON(JavaScript Object Notation) :一种轻量级的数据交换格式,基于JavaScript的一个子集. JSON采用完全独立于语言的文本格式,使JSON成为理想的数据交换语 ...

  4. xcode 插件地址

    http://finalshares.com/read-1104 curl -fsSL https://raw.githubusercontent.com/supermarin/Alcatraz/de ...

  5. SOA Integration Repository Error:Service Provider Access is not available.

    在Oracle EBS Integration Repository中,打开一个Webservice,报了一个警告. 英文: Warning Service Provider Access is no ...

  6. autoit 将输入法修改为英文输入法

    如果能用ControlSend,就不推荐用send,如果非要用send,可以切换输入法为英文再send. $hWnd = WinGetHandle("[ACTIVE]");$hWn ...

  7. Android自动化学习笔记之MonkeyRunner:MonkeyRunner的录制和回放

    ---------------------------------------------------------------------------------------------------- ...

  8. This kind of launch is configured to open the Debug perspective when it suspends.

    This kind of launch is configured to open the Debug perspective when it suspends. 因为设置了断点才会弹出这个,不需要调 ...

  9. leetcode-【简单题】Happy Number

    题目: Write an algorithm to determine if a number is "happy". A happy number is a number def ...

  10. C++小常识笔记

    1.C++的继承保护级别最好是显示的写出来.(注:class 的默认继承为private,struct的默认继承为public). 例: class Base{/**/}; struct D1 : B ...