SQL Server: Delay function “WaitFor”
Sql Server provides a function called “WaitFor”” that can be called to block the execution of your T-SQL code for a specified time or time interval is reached, or a specified statement modifies or returns at least one row. The WaitFor function can be called with two sytles:
1) to wait for a certain point in time
--Code execution is blocked till 6:30 pm WAITFOR TIME '18:30'
2) to wait for a certain amount of time:
--Code execution is blocked for 4 seconds WAITFOR DELAY '00:00:04'
WaitFor has to be employed with a cautious manner for the following reasons:
1. No other requests can run on the same transaction that the WaitFor is running
2. Cursors cannot be opened on WaitFor statement.
3. Views cannot be defined on WaitFor statemtent
1. MSDN Online