Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.
One thing I needed to do lately was test how a calling program would respond to slow code. I decided to use a normal query, but add a WAITFOR() to simulate different delay levels. However, I had to look up the syntax for the call and I decided to blog about it.
The WAITFOR call isn’t a function. I’ve written about that before. Instead, this is listed as a control-of-flow element in the language.
I have a rough idea of how this works. I use
as the basic syntax. SQL Prompt helps me here, since looking this up is a pain and slow. I know there is a time element in here, but I always worry I’ll pick the wrong time and then sit for a long time testing.
The key is this format: hh:mm[[:ss].mss]
To delay for 2 minutes, I write this:
WAITFOR DELAY '00:02:00'
That gives me what I need, and using a string variable, I can control this delay programmatically.
This is a good example of learning a piece of code and writing about it. Short, simple, show how this one works in T-SQL. Add the why, show some code, and results. How you use it, and what you learned.
This was a 10 minute post.