码迷,mamicode.com
首页 > 数据库 > 详细

sql 游标使用

时间:2018-10-09 19:58:43      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:cti   close   locate   rem   sele   eal   var   ber   varchar   

declare
@PASSDate datetime,
@VLPN varchar(50),
@VLPNColor varchar(10),
@nambers int
set @VLPN=‘‘;
set @VLPNColor=‘‘;
set @nambers=947383;
Declare rmd Cursor for
select
VLPN,VLPNColor,PASSDATETIME
from
REMOTEDETECTION
where REMOTEDETECTIONID is null;
Open rmd
Fetch Next From rmd Into @VLPN,@VLPNColor,@PASSDate--取第一条记录存入@result中
While ( @@Fetch_Status=0 )
begin
if(@VLPN!=‘‘ and @VLPNColor!=‘‘ and @PASSDate !=‘‘)
begin
update REMOTEDETECTION set REMOTEDETECTIONID=@nambers where VLPN=@VLPN and VLPNCOLOR=@VLPNColor and PASSDATETIME=@PASSDate;
set @nambers=@nambers+1;
end;
Fetch Next From rmd into @VLPN,@VLPNColor,@PASSDate; ----下一条
end
Close rmd
Deallocate rmd

sql 游标使用

标签:cti   close   locate   rem   sele   eal   var   ber   varchar   

原文地址:https://www.cnblogs.com/luoguixin/p/9762173.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!