使用waitfor time和waitfor delay在一定時間間隔下定時執行批處理

kitesky發表於2013-08-22
使用waitfor time和waitfor delay[@more@]
[case 1]
WAITFOR TIME '01:20:04'
begin
declare @i int = 0
while (@i < 3)
begin
insert into ContentType_Log(TypeID,TypeName,LastUpdateDate)
select TypeID,TypeName,getdate() as LastUpdateDate
from TypeTable
set @i = @i + 1
WAITFOR DELAY '00:00:10'
end
end
GO
[case 2]
WAITFOR TIME '01:23:34'
GO
begin
insert into ContentType_Log(TypeID,TypeName,LastUpdateDate)
select TypeID,TypeName,getdate() as LastUpdateDate
from TypeTable
WAITFOR DELAY '00:00:10'
end
GO 3

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/66009/viewspace-1060870/,如需轉載,請註明出處,否則將追究法律責任。

相關文章