Wednesday, April 9, 2008

Cause a SQL Statement to Wait (Sleep, Pause)

At work I was trying to simulate a query that took a long time to execute, in order to debug a problem that I was tasked to fix. My goal was to write it in such a way that I knew exactly how long it was going to take every time. That's when I came across code that would allow to do exactly that:
WAITFOR DELAY '000:00:20';
SELECT column_list FROM table_name;
This code will wait for 20 seconds and then and then run the code that follows it, which is exactly what I was looking for.

No comments: