Schedule job to execute every 1st week of every month.

  • Hey all.

    How can i schedule a job to execute every day for the first week of every month?

     

    Alex S
  • How about scheduling it to run every day at x time.  Then have the first step of the job checking if the day of the date is greater than 7.  If so, then stop the job.

  • Or you could create 7 monthly schedules for the job, each specifying a different day.  For example:

    schedule 1 - day 1 of every month

    schedule 2 - day 2 of every month

    etc.

    Greg

    Greg

  • Nice alternative .

  • Thanks.  I don't think it's very obvious that a job can have multiple schedules so a lot of people overlook the possibility.

    Greg

    Greg

  • Point well taken.  I've never had to do anything like that so it never came to my mind.

  • I came up with this:

    create

    proc Exec_SQL_JOB

    as

    use

    msdb

    DECLARE

    @PrintMessage NVARCHAR(100)

    SET

    @PrintMessage = N'Todays date is '

    +

    RTRIM(CAST(GETDATE() AS NVARCHAR(30)))

    +

    N'.'+' This Job only executes between 1st and 7th of every month';

    IF

    Datepart(day,getdate()) >=1 and Datepart(day,getdate()) <= 7

    EXEC

    dbo.sp_start_job N'TransferAS'

    else

    PRINT

    @PrintMessage;

    Alex S
  • Thanks for sharing this.  However from now on I'll simply add more than 1 schedule for the job.  Just to try something new .

Viewing 8 posts - 1 through 7 (of 7 total)

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