| title | sp_help_jobcount (Transact-SQL) | ||
|---|---|---|---|
| description | sp_help_jobcount provides the number of jobs that a schedule is attached to. | ||
| author | markingmyname | ||
| ms.author | maghan | ||
| ms.reviewer | randolphwest | ||
| ms.date | 06/23/2025 | ||
| ms.service | sql | ||
| ms.subservice | system-objects | ||
| ms.topic | reference | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
||
| monikerRange | >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current |
[!INCLUDE SQL Server]
Provides the number of jobs that a schedule is attached to.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_help_jobcount
[ [ @schedule_name = ] N'schedule_name' ]
[ , [ @schedule_id = ] schedule_id ]
[ ; ]
The identifier of the schedule to list. @schedule_id is int, with no default.
Either @schedule_id or @schedule_name can be specified.
The name of the schedule to list. @schedule_name is sysname, with no default.
Either @schedule_id or @schedule_name can be specified.
0 (success) or 1 (failure).
Returns the following result set:
| Column name | Data type | Description |
|---|---|---|
JobCount |
int | Number of jobs for the specified schedule. |
This procedure lists the number of jobs attached to the specified schedule.
[!INCLUDE msdb-execute-permissions]
Other users must be granted one of the following [!INCLUDE ssNoVersion] Agent fixed database roles in the msdb database:
- SQLAgentUserRole
- SQLAgentReaderRole
- SQLAgentOperatorRole
For details about the permissions of these roles, see SQL Server Agent Fixed Database Roles.
Only members of sysadmin can view counts for jobs that are owned by others.
The following example lists the number of jobs attached to the NightlyJobs schedule.
USE msdb;
GO
EXECUTE sp_help_jobcount @schedule_name = N'NightlyJobs';
GO