Applies To: SQL Server 2014, SQL Server 2016 Preview
Returns information about the jobs that a particular schedule is attached to.
Applies to: SQL Server (SQL Server 2008 through current version).
- [ @schedule_id = ] schedule_id
The identifier of the schedule to list information for. schedule_id is int, with no default. Either schedule_id or schedule_name may be specified.
- [ @schedule_name = ] 'schedule_name'
The name of the schedule to list information for. schedule_name is sysname, with no default. Either schedule_id or schedule_name may be specified.
0 (success) or 1 (failure)
Returns the following result set:
Unique ID of the job.
Name of the server from which the job came.
Name of the job.
Indicates whether the job is enabled to be executed.
Description for the job.
ID of the step in the job where execution should begin.
Bitmask indicating under what circumstances a notification event should be logged to the Microsoft Windows application log. Can be one of these values:
0 = Never
1 = When a job succeeds
2 = When the job fails
3 = Whenever the job completes (regardless of the job outcome)
Bitmask indicating under what circumstances a notification e-mail should be sent when a job completes. Possible values are the same as for notify_level_eventlog.
Bitmask indicating under what circumstances a network message should be sent when a job completes. Possible values are the same as for notify_level_eventlog.
Bitmask indicating under what circumstances a page should be sent when a job completes. Possible values are the same as for notify_level_eventlog.
E-mail name of the operator to notify.
Name of the computer or user used when sending network messages.
Name of the computer or user used when sending a page.
Bitmask indicating under what circumstances the job should be deleted when a job completes. Possible values are the same as for notify_level_eventlog.
Date the job was created.
Date the job was last modified.
Version of the job (automatically updated each time the job is modified).
Date the job last started execution.
Time the job last started execution.
Outcome of the job the last time it ran:
0 = Failed
1 = Succeeded
3 = Canceled
5 = Unknown
Date the job is scheduled to run next.
Time the job is scheduled to run next.
Identification number of the next run schedule.
Current execution status.
Current execution step in the job.
If the job is running and the step has been retried, this is the current retry attempt.
Number of job steps the job has.
Number of job schedules the job has.
Number of target servers the job has.
Type of the job:
1 = Local job.
2 = Multiserver job.
0 = Job has no target servers.
This procedure lists information about jobs attached to the specified schedule.
By default, members of the sysadmin fixed server role can execute this stored procedure. Other users must be granted one of the following SQL Server Agent fixed database roles in the msdb database:
For details about the permissions of these roles, see SQL Server Agent Fixed Database Roles.
Members of SQLAgentUserRole can only view the status of jobs that they own.
The following example lists the jobs attached to the NightlyJobs schedule.
USE msdb ; GO EXEC sp_help_jobs_in_schedule @schedule_name = N'NightlyJobs' ; GO