Today is discovered a command in T-SQL I never have used before: WAITFOR

This is not the most important command 🙂 But nice to if you need to wait for a predefined number of seconds or until a certain time of day in your scripts.


  • WAITFOR DELAY ’00:00:20′;
    pauses code execution for 20 seconds
  • WAITFOR TIME ’23:46:00′;
    pauses execution to wait for a specific time

This command can be used to syncronize processes in a simple fashion from your scripts. These scripts often run from command line, scheduled tasks or similar applications.


2 thoughts on “SQL 2012: WAITFOR DELAY/TIME

  1. First of all I would like to say great blog! I had
    a quick question which I’d like to ask if you don’t mind.
    I was curious to find out how you center yourself and clear
    your mind prior to writing. I’ve had a tough time clearing my mind in getting my thoughts out
    there. I do enjoy writing but it just seems like the first 10
    to 15 minutes are generally wasted simply just trying to
    figure out how to begin. Any recommendations or tips?

    Many thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s