WAITFOR

WAITFOR is a SQL Server command used to add a delay or to set a specific time when the subsequent queries or statements should be executed. It can be configured for a specified amount of time or until a specific time of the day. There are two types of WAITFOR command: WAITFOR DELAY and WAITFOR TIME.

Example

BEGIN
PRINT GETDATE();
WAITFOR DELAY '00:00:02';
PRINT GETDATE();
END

Output

Oct 11 2021 12:00:00
Oct 11 2021 12:00:02

Explanation

The WAITFOR statement in SQL Server is used to delay the execution of commands. In the above example, the system gets the current timestamp, waits for 2 seconds, then gets and prints the new timestamp which is 2 seconds later than the first one.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.