May 1, 2007 at 12:52 pm
Hey all.
How can i schedule a job to execute every day for the first week of every month?
May 1, 2007 at 1:41 pm
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.
May 1, 2007 at 2:09 pm
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
May 1, 2007 at 2:19 pm
Nice alternative .
May 1, 2007 at 3:16 pm
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
May 1, 2007 at 5:04 pm
Point well taken. I've never had to do anything like that so it never came to my mind.
May 2, 2007 at 9:22 am
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
@PrintMessage;
May 2, 2007 at 9:28 am
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