SQL Delay operation

Source: Internet
Author: User

--delay or suspend execution of the program using the WAITFOR statement

--waitfor{delay ' time ' |time ' time '}

Delay is the maximum interval of time to 24 hours

Time is specified when execution

WAITFOR DELAY ' 00:00:10 '--delayed 10 seconds

A. Using WAITFOR time

The following example executes a stored procedure sp_update_jobat night 10:20 (22:20).

Copy Code
Use msdb; EXECUTE sp_add_job @job_name = ' testjob '; Beginwaitfor time ' 22:20 '; EXECUTE sp_update_job @job_name = ' testjob ', @new_name = ' updatedjob '; END; GO
B. Using WAITFOR DELAY

The following example executes a stored procedure after a two-hour delay.

Copy Code
Beginwaitfor DELAY ' 02:00 '; EXECUTE sp_helpdb; END; GO
This delay is usually not retired nature ah. However, the problem occurs when the subscription is synchronized, or when the amount of data is too large. Lose the data, or the table lock dead. The problem is very much, the extra 1 should be considered in batches. The extra 5000 must be in batches.

SQL Delay operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.