Microsoft KB Archive/50209
PRB: Using Datetime Variable w/ WAITFOR TIME or WAITFOR DELAY ID Number: Q50209
1.10 1.11 4.20 OS/2
SYMPTOMS Neither WAITFOR TIME nor WAITFOR DELAY will accept a variable for the “time” parameter.
CAUSE This is a limitation of SQL, and currently there are no plans to modify this behavior.
RESOLUTION If you try to use a datetime variable with WAITFOR TIME or WAITFOR DELAY, as the following sequence of ISQL statements attempt, you receive a syntax error on line 3, referring to the variable “@i”. There is no way to work around this limitation. You must use a constant value, as demonstrated in the second example listed below.
The following sequence of statements generates a syntax error on line 3:
1>DECLARE @i datetime 2>SELECT @i="02:25" 3>WAITFOR TIME @i 4>GO
The following sequence of statements works correctly:
1>WAITFOR TIME "02:25" 2>GO
Additional reference words: Transact-SQL