当前位置:Gxlcms > 数据库问题 > SQL中游标的用法

SQL中游标的用法

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


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   

人气教程排行