SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


WAITFOR


WAITFOR

Author
Message
Jamie-2229
Jamie-2229
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3129 Visits: 836
WAITFOR
{
DELAY 'time_to_pass'
| TIME 'time_to_execute'
| [ ( receive_statement ) | ( get_conversation_group_statement ) ]
[ , TIMEOUT timeout ]
}


I wondered when I answered the question about the service broker but it wasn't mentioned in the BOL so I figured I was okay.

http://msdn.microsoft.com/en-us/library/ms187331.aspx?n=0

Jamie
Mauve
Mauve
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1736 Visits: 2054
I somewhat disagree that a TIMEOUT can be used to end a WAITFOR. It cannot be used independently and is only an optional modifier of the Service Broker message.


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
chajere
chajere
SSC-Enthusiastic
SSC-Enthusiastic (196 reputation)SSC-Enthusiastic (196 reputation)SSC-Enthusiastic (196 reputation)SSC-Enthusiastic (196 reputation)SSC-Enthusiastic (196 reputation)SSC-Enthusiastic (196 reputation)SSC-Enthusiastic (196 reputation)SSC-Enthusiastic (196 reputation)

Group: General Forum Members
Points: 196 Visits: 54
receive_statement

Is a valid RECEIVE statement.
Important:
WAITFOR with a receive_statement is applicable only to Service Broker messages. For more information, see RECEIVE (Transact-SQL).


BigGrin
Ric Sierra
Ric Sierra
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1479 Visits: 342
I think so.
Timeout option is not directly related with WAITFOR TSQL is an optional part.
Ric Sierra
Ric Sierra
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1479 Visits: 342
I agree.
Timeout is an optional syntax of WAITFOR TSQL command
john.arnott
john.arnott
SSCommitted
SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)

Group: General Forum Members
Points: 1958 Visits: 3059
This is a good QOD in that it prompted a careful reading of the syntax of an unfamiliar (to me, anyway) feature. The keywords "DELAY", "TIME", and "TIMEOUT" all sound so much like the same sort of thing that I had to read the definition of those terms two or three times. Let's see if I've got them straight now:

-- DELAY lets you specify an interval to wait after the WAITFOR statement is encountered before the rest of the SQL is executed.
-- TIME is an alternative to DELAY in that it lets you specify a specific time of day at which you want your SQL to continue to execute.
-- TIMEOUT gives you a safety net if you're waiting for a Service Broker message. Execution proceeds if the message hasn't arrived within the time you're willing to wait for it.

So, yes, all four options are correct answers as to what will terminate a WAITFOR, allowing the rest of the SQL to continue.
Anipaul
Anipaul
SSCertifiable
SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)

Group: General Forum Members
Points: 7227 Visits: 1407
Nice question.............Smile



Christian Buettner-167247
Christian Buettner-167247
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3543 Visits: 3889
I also missed that one because of the TIMEOUT. But re-reading the question revealed that the question writer had this in mind when choosing his wording.
Tricky :-)

Best Regards,

Chris Büttner
TomThomson
TomThomson
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14202 Visits: 12197
Mauve (6/17/2008)
I somewhat disagree that a TIMEOUT can be used to end a WAITFOR. It cannot be used independently and is only an optional modifier of the Service Broker message.

I agree with Mauve, you can wait for a message or you can wait for whichever comes first, a message of a timeout, but you can't wait for just a timeout.

Tom

bitbucket-25253
bitbucket-25253
SSCertifiable
SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)

Group: General Forum Members
Points: 7773 Visits: 25280
Tom.Thomson (12/23/2010)
Mauve (6/17/2008)
I somewhat disagree that a TIMEOUT can be used to end a WAITFOR. It cannot be used independently and is only an optional modifier of the Service Broker message.

I agree with Mauve, you can wait for a message or you can wait for whichever comes first, a message of a timeout, but you can't wait for just a timeout.


Bored, not enough to do?

visiting these QODs almost a year and a half after they were original posted..

Suggestion .. put your vast knowledge of SQL to a useful purpose for the community ... write a couple of articles .... pass some of your vast knowledge to others.

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search