I must confess, I have often wanted to use WAITFOR TIME because that's what I have: a desired point in time that I want the code to wait for.

However, I have always ended up using WAITFOR DELAY even if it means doing extra work; e.g., a DATEDIFF calculation.

My concern is this line from the Help: If the current server time is greater than the time specified, processing is suspended until that time on the following day.

Consider the following pseudo-code:

SET @t = obtain or calculate a desired "wait for" time 
   that is 0.01 seconds in the future;
Perform some operation that might take more than 0.01 seconds to perform;

Most of the time, WAITFOR will wait for less than 1/10th of a second. Sometimes, however, CURRENT TIME may be > @t, which means the WAITFOR waits for about 24 hours.

Egad! Zounds! That's not what I want!

What I think I want is WAITFOR TIMESTAMP. Until then, I'll stick to WAITFOR DELAY.

asked 25 Mar '10, 09:46

Breck%20Carter's gravatar image

Breck Carter
accept rate: 21%

I would vote also for an enhanced behaviour. WAITFOR TIME is only usefull if you build something like a scheduler.

permanent link

answered 21 Oct '10, 07:49

Thomas%20Duemesnil's gravatar image

Thomas Dueme...
accept rate: 15%


Kind of funny, Breck's question has WAITed FOR a long TIME to get an answer:)

(21 Oct '10, 08:32) Volker Barth

I used the Command the first time and the documentation is really strange. Wine also gets better when you let it breath.

(21 Oct '10, 10:04) Thomas Dueme...
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 25 Mar '10, 09:46

question was seen: 714 times

last updated: 29 Oct '10, 13:24