Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I want to create a SQL agent schedule that occurs during a date range. I can't use "recurs every n weeks" because the process that it will fire off will change with each month.
I need to set the frequency to be akin to occurs monthly, 1st Monday through the 2nd Friday of every 1 month. That way I am assured to be only running the process starting with the first full week of every month

Am I crazy for thinking of a schedule like this? Shirley(sic) I can't be the only one. I have looked at sp_add_schedule for any hints, none to be found there. I have tried Googling, but I can't come up with the right query syntax thus keep coming up empty.

Perhaps if one could help me come up with the correct question, that could lead me in the right direction.

::Update1: I am going to add date logic to the script.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

I have dome something like this before by putting logic into the code you are calling to verify if it's in that range and just schedule to run everyday and if it's in that range execute, otherwise exit out gracefully?

share|improve this answer
    
Interesting. I'll have to check that out –  RateControl Jan 6 '12 at 19:08
    
I am going to add date logic to the task. Thanks! –  RateControl Jan 6 '12 at 19:55
    
Yeah, for anything more complicated than run every day or every Monday, this is usually the way to go. Just put a note in your wiki or in the scheduling agent call that says that there is "will execute first week of the month" logic in the sproc. –  Brandon Jan 6 '12 at 21:18
add comment

How about mutiple, recurring Monthly Schedules where you have selected the first Monday of every 1 month on Schedule 1, the first Tuesday of every 1 month on Schedule 2, ... the second Friday of every 1 month? See the following pic to get the idea of what I'm thinking: enter image description here

share|improve this answer
    
Yeah, that is what I was thinking about setting up as a last resort. I just figured someone else out there had already done this. Thanks! –  RateControl Jan 6 '12 at 18:35
    
While I applaud your effort in keeping the solution within the sql agent scheduling, I am going to go a different way. –  RateControl Jan 6 '12 at 19:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.