Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am testing a monitoring application against a SQL Server 2000 instance. How can I write a T-SQL query that takes an amount of time that I specify? For example, most scripting languages have something like the SLEEP command which allows you to pause script execution for a specified amount time. I am looking for something similar that is compatible with SQL Server 2000. This is intended to test the long-running query threshold settings of the monitoring application.

share|improve this question
up vote 19 down vote accepted

If you are looking for a function to block the execution batch for a specified amount of time, you can use WAITFOR in SQL Server 2000. This function is similar to SLEEP function in Oracle. Usage examples:

WAITFOR DELAY '00:00:30';     -- wait for 30 seconds
WAITFOR TIME '13:30';         -- wait until server time is 13:30
share|improve this answer
WAITFOR works perfectly for my intended purpose, Binaya. I appreciate the quick response! Thanks for your time. – Jinxter May 6 '14 at 19:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.