Skip to content

Latest commit

 

History

History
99 lines (68 loc) · 2.84 KB

File metadata and controls

99 lines (68 loc) · 2.84 KB
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
sp_help_jobcount
sp_help_jobcount_TSQL
helpviewer_keywords
sp_help_jobcount
dev_langs
TSQL
monikerRange >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current

sp_help_jobcount (Transact-SQL)

[!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

Syntax

sp_help_jobcount
    [ [ @schedule_name = ] N'schedule_name' ]
    [ , [ @schedule_id = ] schedule_id ]
[ ; ]

Arguments

[ @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.

[ @schedule_name = ] N'schedule_name'

The name of the schedule to list. @schedule_name is sysname, with no default.

Either @schedule_id or @schedule_name can be specified.

Return code values

0 (success) or 1 (failure).

Result set

Returns the following result set:

Column name Data type Description
JobCount int Number of jobs for the specified schedule.

Remarks

This procedure lists the number of jobs attached to the specified schedule.

Permissions

[!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.

Examples

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

Related content