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

SQL中游标的用法

时间:2019-05-30 12:11:46      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:oca   用法   object_id   arch   find   taf   ext   tmp   dea   


if object_id(‘##tmp1‘) is not null
drop table #tmp1
select staffno, paydate
into #tmp1
from dbo.OSS_ClockingDetail
where paydate>getdate()-50 and ProcessInd=‘P‘ and ActionBy=‘D‘ and paymonth is null
group by staffno,paydate
declare @staffno varchar(6)
declare @paydate datetime
declare cur cursor for select staffno, paydate
from #tmp1
open cur
fetch next from cur into @staffno,@paydate
WHILE (@@FETCH_STATUS = 0)
begin
update dbo.OSS_Rawclocking set intime=‘‘,outtime=‘‘,payhour=0,offind=0 where paydate=@paydate and staffno=@staffno
update dbo.OSS_ClockingDetail set ProcessInd=‘U‘ where paydate=@paydate and ProcessInd=‘P‘ and ActionBy=‘D‘ and paymonth is null and staffno=@staffno
fetch next from cur into @staffno,@paydate
end
close cur
DEALLOCATE cur

SQL中游标的用法

标签:oca   用法   object_id   arch   find   taf   ext   tmp   dea   

原文地址:https://www.cnblogs.com/xiaoyichong/p/10948723.html

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