3

I have created a job in sql. My requirement is that the job should get executed annually in 31st of march. While creating the steps, i was not able to find Yearly frequency occurance.

Can anybody tell me how to achieve this. Thanks in advance.

4

2 回答 2

2

There's no such option - you'll have to schedule it to run on the 31st of every month. Then, as the first step, detect if its not the 31st of march and cause the job to complete early.

I normally write such steps as an obvious error, and use that to control the flow of the job - something like:

IF DATEPART(month,CURRENT_TIMESTAMP) != 3
BEGIN
    EXEC('select * from nonexistenttable')
END
于 2013-06-17T07:10:11.627 回答
2

For anyone else stumbling across this you can set up a job that runs on a specific day on a rolling basis, in this case every 12 months on March 31st.

Under Frequency - set the day to the 31st of every 12 month(s). Under Duration - set the start date to March 31st with no end date.

sp_add_jobschedule [ @job_id = ] job_id, | [ @job_name = ] 'job_name'
 , @freq_type = 16  
 , @freq_interval = 1  
 , @freq_recurrence_factor = 12
 , @active_start_date = 20180331

or

Job Schedule Setup to run annually

于 2016-03-22T20:45:08.347 回答