So I'm wanting to batch a number of stored procedures into one job and would like a number of the procedures to run on a schedule different than that of the main job without setting up a new job for each schedule type.
Is this possible?
So I'm wanting to batch a number of stored procedures into one job and would like a number of the procedures to run on a schedule different than that of the main job without setting up a new job for each schedule type.
Is this possible?
If the jobs are all scheduled to run at the top of the hour, then you could simply have a single job, with a single step, and schedule the job to run every hour (or on select hours). Then the step can have logic like this:
DECLARE @h INT = DATEPART(HOUR, CURRENT_TIMESTAMP);
IF @h = 1
BEGIN
EXEC dbo.ProcedureToRunAt1AM;
END
IF @h = 2
BEGIN
EXEC dbo.OneProcedureToRunAt2AM;
EXEC dbo.AnotherProcedureToRunAt2AM;
END
IF @h IN (4,16)
BEGIN
EXEC dbo.OneProcedureToRunAt4AMand4PM;
END
If you need it to be more granular, you can check the minute, minute/10, etc.