Exploring the T-SQL Enhancements in SQL Server 2005 : The WAITFOR Command

10/13/2010 9:34:54 AM
The WAITFOR command has also been enhanced in SQL Server 2005. In the past, WAITFOR waited for a specified duration or a supplied datetime value. Now, as with the TOP enhancements, you can use WAITFOR with an SQL expression. You can essentially use the WAITFOR function to wait for a T-SQL statement to affect at least one row. (You can also set a timeout on that SQL expression.) You can now specify WAITFOR to wait not only in SELECT statements, but also in INSERT, UPDATE, DELETE, and RECEIVE statements. In essence, SELECT statements won’t complete until at least one row is produced, and DML statements won’t complete until at least one row is affected.

Here is the syntax:

WAITFOR(<statement>) [,TIMEOUT <timeout_value>]

This feature creates a new alternative to polling. For example, you can use WAITFOR to select all the records in a log or a queue table:

PS4 game trailer XBox One game trailer
WiiU game trailer 3ds game trailer
Top 10 Video Game
-   Company of Heroes 2: The British Forces [PC] Trailer
-   SDCC 2015: Plants vs. Zombies Garden Warfare 2 | Seeds of Time Map Gameplay Reveal
-   Microsoft HoloLens: Partner Spotlight with Case Western Reserve University
-   Cossacks 3 [PC] Musketeer Animations Trailer
-   Call Of Duty: Black Ops III [PS4/XOne/PC] Zombies - Shadows of Evil Trailer
-   No Time To Explain [XOne/PC] Multiplayer Trailer
-   Bierzerkers [PC] Early Access Trailer
-   Downward [PC] Kickstarter Trailer
-   Grip [PS4/PC] Trailer
-   Hitman [PS4/XOne/PC] Debut Trailer
-   Gears of War: Ultimate Edition [XOne] Recreating the Cinematics Trailer
-   Gravity Falls: Legend of the Gnome Gemulets [3DS] Debut Trailer
-   Street Fighter V [PS4/PC] Ken Trailer
-   Doctor Who | Series 9 Teaser Trailer
-   Transformers: Devastation | Gameplay Trailer (SDCC 2015)
Game of War | Kate Upton Commercial