The WAITFOR DELAY system function is the best tool we have in Microsoft SQL Server to introduce a pause in our SQL code.
The syntax is extremely simple. We just run the WAITFOR DELAY statement on its own, like this:
WAITFOR DELAY '00:00:10'
You can see how in single quotes, we outline the duration of the delay. In this example, we are delaying for 10 seconds.
Notice you don’t need to call the WAITFOR DELAY function within a SELECT statement or any other clause. You can just run it on its own.
This offers a simple, easy way to introduce a pause in your code!
Next Steps:
Leave a comment if you found this tutorial helpful!
Here’s a link to the official Microsoft article that talks about WAITFOR DELAY
Thank you very much for reading!
Make sure you subscribe to my newsletter to receive special offers and notifications anytime a new tutorial is released!
If you have any questions, or if you are struggling with a different topic related to SQL Server, I’d be happy to discuss it. Leave a comment or visit my contact page and send me an email!