I must confess, I have often wanted to use WAITFOR TIME because that's what I have: a desired point in time that I want the code to wait for.
However, I have always ended up using WAITFOR DELAY even if it means doing extra work; e.g., a DATEDIFF calculation.
My concern is this line from the Help: If the current server time is greater than the time specified, processing is suspended until that time on the following day.
Consider the following pseudo-code:
SET @t = obtain or calculate a desired "wait for" time that is 0.01 seconds in the future; Perform some operation that might take more than 0.01 seconds to perform; WAITFOR TIME @t;
Most of the time, WAITFOR will wait for less than 1/10th of a second. Sometimes, however, CURRENT TIME may be > @t, which means the WAITFOR waits for about 24 hours.
Egad! Zounds! That's not what I want!
What I think I want is WAITFOR TIMESTAMP. Until then, I'll stick to WAITFOR DELAY.
asked 25 Mar '10, 09:46
I would vote also for an enhanced behaviour. WAITFOR TIME is only usefull if you build something like a scheduler.
answered 21 Oct '10, 07:49