当前位置:Gxlcms > 数据库问题 > sql 游标使用

sql 游标使用

时间:2021-07-01 10:21:17 帮助过:4人阅读

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   

人气教程排行