Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

SQL Server Job Scheduling Expand / Collapse
Author
Message
Posted Friday, November 16, 2007 1:30 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 6:46 AM
Points: 21, Visits: 244
Using DTS in 2000 I run a check for every second Thursday with the following code and set the 'job' to run every Thursday. If it is the right day the DTS continues otherwise it simply fails.

'*******************************************************
' Visual Basic ActiveX Script
'*******************************************************

' Test for the second week since a Job can only be set
' to work within a week. Prime with a run date.

Function Main()

Dim myDate
Dim oddEven

myDate = datediff("ww","8/10/2007",date())
oddEven = (myDate Mod 2)

if oddEven = 0 then

Main = DTSTaskExecResult_Success

else
Main = DTSTaskExecResult_failure
end if

End Function
Post #423217
Posted Friday, November 16, 2007 2:13 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, September 13, 2010 1:05 PM
Points: 2, Visits: 11
One thing Peter failed to mention is that if you want to see lots of job history, be sure the job history log is big enough (Job System within SQL Server Agent properties).
Post #423231
Posted Friday, November 16, 2007 2:42 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, July 9, 2014 12:14 PM
Points: 148, Visits: 655
An easy way to do it is to have a first step that determines if today is the day the dw_job should run or the dm_job. You can cause the step to fail based on your criteria of choice (you can use a SQL step or ActiveX to do this). Then it's simply On Failure... load one, or On Succes.... load the other, in steps 2 and 3. Remember to quit on success and failure in 2, tho.. ;)


Post #423235
Posted Friday, November 16, 2007 3:53 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, May 9, 2012 10:26 AM
Points: 891, Visits: 1,958
Rasool Omidakhsh (11/16/2007)
...I have to run this dm_job everyday. ... [dw_job] I have to run this job on every second thursday. ...

I don't see a problem with this, I would do it along these lines. dw_job has one schedule, occurs monthly, 2nd Thursday, runs once at 00:45. dm_job has five schedules, first one is weekly on Friday through Wednesday, the other schedules run 1st, 3rd, 4th, and last Thursday.

Unless I misunderstood your saying second Thursday and you meant every other Thursday, in which case do dw as Weekly, Every 2 Weeks, Starting 11/01/2007, then have dm_job doing the Thursday run Every 2 Weeks starting 11/08/2007. dm would still need the Friday-Wednesday schedule.

I think that would do it, but I could be wrong.
Post #423251
Posted Monday, December 10, 2007 10:49 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, February 14, 2008 9:14 AM
Points: 1, Visits: 1
Were you able to complete the conditional scheduling for a SQL report?
Post #431436
Posted Thursday, February 14, 2008 2:05 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, August 7, 2010 12:46 AM
Points: 2, Visits: 24
Excellent article on Jobs.
Post #455561
Posted Friday, November 26, 2010 6:50 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, November 26, 2010 6:47 AM
Points: 1, Visits: 0
Thanks for such good article
Post #1026767
Posted Wednesday, February 1, 2012 10:48 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, February 1, 2012 10:46 AM
Points: 1, Visits: 0
hi ,

i c your msg, and i have the same question. Can I perform this schedule jobs dynamically, with some conditional parameters ... ?? .. if you know something about it, please contact me ...
Post #1245222
Posted Thursday, September 27, 2012 7:18 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, June 19, 2013 1:06 AM
Points: 1, Visits: 2
i have set up a job to run every five minutes.
If somehow the job takes more than five minutes in execution, will the sql scheduler run another instance of same job on five minutes cycle? when the last execution has not been completed?
Post #1365233
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse