SQL Server 2008 - Worth the Wait
Have you ever wanted to create a report listing all of the SQL Server jobs on your SQL Server 7.0 or 2000 servers? This is easy if you use the stored procedure I have created just for this purpose. The stored procedure, called sp_JobSchedule_rpt, creates this report by joining the sysjobs and sysjobschedules tables and creating a resultset.
To make the report easy to read, I have had to substitute the various integer values found in these tables with readable values. The first part of the stored procedure generates the list of jobs and the days to run for weekly scheduled jobs. The second part is written with CASE statements to incorporate all the possible combinations listed under the sysjobschedules table.
Making the Data Readable
The following are the various numeric entries and their string values, used in the stored procedure, to make it more readable.freq_type int Frequency of the schedule execution:1 = Once4 = Daily8 = Weekly16 = Monthly32 = Monthly relative64 = Execute when SQL Serverfreq_interval int Value indicating on which days the schedule runs.If freq_type is 4 (daily), the value is every freq_interval days.If freq_type is 8 (weekly), the value is a bitmask indicating the days in which weekly schedules are run. The freq_interval values are:1 = Sunday2 = Monday4 = Tuesday8 = Wednesday16 = Thursday32 = Friday64 = SaturdayIf freq_type is 16 (monthly), the value is freq_interval day of the month.If freq_type is 32 (monthly relative), freq_interval can be one of these values:1 = Sunday 2 = Monday3 = Tuesday4 = Wednesday5 = Thursday6 = Friday7 = Saturday8 = Day9 = Weekday 10 = Weekend dayfreq_subday_type int Units for the freq_subday_interval:1 = At the specified time2 = Seconds4 = Minutes8 = Hoursfreq_subday_interval int Number of freq_subday_type periods to occur between each scheduled execution of the job.freq_relative_interval int Scheduled job’s occurrence of the freq_interval in each month when freq_type is 32 (monthly relative):1 = First2 = Second4 = Third8 = Fourth16 = Lastfreq_recurrence_factor int Number of weeks or months between the scheduled execution of the job.