Explain WaitFor Delay And WaitFor Time in SQL Server?


WaitFor Delay : It is used for a specified duration relative to the current time.

SELECT GETDATE();
WAITFOR DELAY '00:00:05'; —- Wait 5 seconds
SELECT GETDATE();


WaitFor Time : It is used for actual time of day.

SELECT GETDATE();
WAITFOR TIME '20:00'; -- Wait for 8pm
SELECT GETDATE();