SQL Job Schedule Question

  • Hi all

    Is it possible to stop a job schedule from running on say that last Thursday of the month, i.e. I have a schedule that runs weekly, but I also have one that runs monthly however I don't want the weekly schedule to run on the same day that the monthly is running!

    Hope that makes sense

    Thanks

  • If your monthly job starts to run before the weekly job is scheduled to run, you could add a step to disable the weekly job

    DECLARE @JobName sysname

    SET @JobName = 'Your weekly job name'

    UPDATE MSDB.dbo.sysjobs

    SET Enabled = 0

    WHERE [Name] = @JobName;

    and then re-enable the weekly job

    DECLARE @JobName sysname

    SET @JobName = 'Your weekly job name'

    UPDATE MSDB.dbo.sysjobs

    SET Enabled = 1

    WHERE [Name] = @JobName;

    But I am hoping someone comes along with a more elegant solution for you 🙂

    Ian

  • Seems not too bad apart from when the job fails without re-enabling the other job, then manual intervention would be required. I appreciate the reply non the less.

    Thanks

  • Have the daily job check the day of the month before it starts. If 'today' is the the last Thursday of the month just exit the procedure.

    The probability of survival is inversely proportional to the angle of arrival.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply