WAITFOR statement used to delay execution of T-SQL command for a specified period of time. This can be used to block the execution of batch statement, stored procedure and T SQL commands for a specified time.

There are two parameters can be used with WAITFOR statement.

clip_image001

Let us create simple stored procedure

clip_image002

Let us execute above stored procedure after delay of 1 minute

clip_image003

In above query we are using delay with WAITFOR.

clip_image004

Above query will execute stored procedure at 10.06PM. Time we will need to provide on scale of 24 hrs. For 1 Pm we need to give input as 13.00.

Advertisements

2 thoughts on “SQL Server: WAITFOR Statement

  1. hey there and thank you for your information
    – I have certainly picked up something new from
    right here. I did however expertise a few technical issues using this site, since I experienced to
    reload the website lots of times previous to I could get it to load properly.
    I had been wondering if your web hosting is OK? Not that I’m complaining, but slow loading instances times will sometimes affect your placement in google and could damage your quality score if ads and marketing with Adwords. Well I am adding this RSS to my email and could look out for much more of your respective fascinating content. Ensure that you update this again soon.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s