RSS Feed

SQL Server - WAITFOR

SQL Server - WAITFOR


WAITFOR is less known feature of SQL Server. WAITFOR blocks the execution of a batch, stored procedure, or transaction until a specified time or time interval is reached, or a specified statement modifies or returns at least one row. [MSDN]

Example 1 of WAITFOR

You can observe that there is a delay of 3 seconds between the FIRST_DATE and SECOND_DATE.


Example 2 of WAITFOR

Here, in this example, the SELECT query executes exactly at the given time i.e. “16:17:15”.