随手记--关于SQL Server中的存储过程使用游标

该博客介绍了一个创建名为proc_Updatessyj的存储过程,通过游标遍历TJDAGL_PhysicalUser表中的记录,查询需要修改Color的登记流水号,并调用PROC_SetFourColorWarning存储过程进行警告设置。
摘要由CSDN通过智能技术生成
Create procedure [dbo].[proc_Updatessyj] --创建存储
as 
begin
    declare @result VARCHAR(30)  --用来处理结果的变量
   --声明一个游标
      Declare curStudentFee Cursor for 
   --查询语句(查询所有需要修改Color的登记流水号)
      select RefNo from dbo.TJDAGL_PhysicalUser  
   --打开游标
      Open curStudentFee
      --循环并提取记录
  Fetch Next From curStudentFee Into @result--取第一条记录存入@result中
  While (@@Fetch_Status=0)   --有记录
        begin
		declare @Str varchar(max)
        SET @Str=''
		--print(@result)
        select @Str=RefNo from dbo.TJDAGL_PhysicalUser  where  RefNo=@result
        exec dbo.PROC_SetFourColorWarning @Str
	 Fetch Next From curStudentFee into @result----下一条
       end  
    --关闭游标   
      Close curStudentFee
  --释放游标
      Deallocate curStudentFee
end --存储结束

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值