WAITFOR query in SQL

WAITFOR used to pauses the execution of query from certain time.

There are two type's of Wait for.

  1. WAITFOR DELAY
  2. WAITFOR TIME

1. WAITFOR DELAY

WAITFOR DELAY Cause the execution to delay from specified duration. For example it pause's the execution for 5 second's.

Example

  1. WAITFOR DELAY '00:00:05'  
  2. SELECT * FROM EMP  
waitfor query

2. WAITFOR TIME

WAITFOR TIME is pause's the execution wait for specified time. For example '13:15:00' whenever time reached the query will be executed.
  1. WAITFOR TIME '13:15:00'  
  2. SELECT * FROM EMP  
  3. SELECT GETDATE()  
waitfor time