sp_help_schedule (Transact-SQL)
列出有关计划的信息。
语法
sp_help_schedule 
     [ @schedule_id = ] id ,
     [ @schedule_name = ] 'schedule_name' 
     [ , [ @attached_schedules_only = ] attached_schedules_only ]
     [ , [ @include_description = ] include_description ]
参数
[ @schedule_id = ] id
要列出的计划的标识符。schedule_name 的数据类型为 int,无默认值。可以指定 schedule_id 或 schedule_name。[ @schedule_name = ] 'schedule_name'
要列出的计划的名称。schedule_name 的数据类型为 sysname,无默认值。可以指定 schedule_id 或 schedule_name。[ @attached_schedules_only = ] attached_schedules_only ]
指定是否仅显示作业附加到的计划。attached_schedules_only 的数据类型为 bit,默认值为 0。当 attached_schedules_only 为 0 时,将显示所有计划。当 attached_schedules_only 为 1 时,结果集只包含附加到作业的计划。[ @include_description = ] include_description
指定是否在结果集中包含说明。include_description 的数据类型为 bit,默认值为 0。当 include_description 为 0 时,结果集的 schedule_description 列包含一个占位符。如果 include_description 为 1,则计划的说明将包含在结果集中。
返回代码值
0(成功)或 1(失败)
结果集
此过程返回以下结果集:
列名  | 
数据类型  | 
说明  | 
|---|---|---|
schedule_id  | 
int  | 
计划标识号。  | 
schedule_uid  | 
uniqueidentifier  | 
计划的标识符。  | 
schedule_name  | 
sysname  | 
计划名称。  | 
enabled  | 
int  | 
指示是启用计划 (1) 还是不启用计划 (0)。  | 
freq_type  | 
int  | 
指示何时执行作业的值。 1 = 一次 4 = 每天 8 = 每周 16 = 每月 32 = 每月,相对于 freq_interval 64 = 当 SQLServerAgent 服务启动时运行。  | 
freq_interval  | 
int  | 
执行作业的天数。该值依赖于 freq_type 的值。有关详细信息,请参阅 sp_add_schedule (Transact-SQL)。  | 
freq_subday_type  | 
int  | 
freq_subday_interval 的单位。有关详细信息,请参阅 sp_add_schedule (Transact-SQL)。  | 
freq_subday_interval  | 
int  | 
在每次执行作业之间发生的 freq_subday_type 的周期数。有关详细信息,请参阅 sp_add_schedule (Transact-SQL)。  | 
freq_relative_interval  | 
int  | 
在每个月中,计划作业的 freq_interval 的出现次数。有关详细信息,请参阅 sp_add_schedule (Transact-SQL)。  | 
freq_recurrence_factor  | 
int  | 
作业的已计划执行日期之间的间隔月数。  | 
active_start_date  | 
int  | 
激活计划的日期。  | 
active_end_date  | 
int  | 
计划的结束日期。  | 
active_start_time  | 
int  | 
计划开始的时间。  | 
active_end_time  | 
int  | 
计划结束的时间。  | 
date_created  | 
datetime  | 
创建计划的日期。  | 
schedule_description  | 
nvarchar(4000)  | 
对计划的英语说明(如果需要的话)。  | 
job_count  | 
int  | 
返回引用此计划的作业数。  | 
注释
如果不提供参数,则 sp_help_schedule 将列出实例中所有计划的信息。
权限
默认情况下,只有 sysadmin 固定服务器角色的成员才可以执行此存储过程。其他用户必须被授予 msdb 数据库中下列 SQL Server 代理固定数据库角色的权限之一:
SQLAgentUserRole
SQLAgentReaderRole
SQLAgentOperatorRole
有关这些角色的权限的详细信息,请参阅 SQL Server 代理固定数据库角色。
SQLAgentUserRole 的成员只能查看其拥有的计划。
示例
A. 列出实例中所有计划的信息
以下示例列出了实例中所有计划的信息。
USE msdb ;
GO
EXEC dbo.sp_help_schedule ;
GO
B. 列出特定计划的信息
以下示例列出了名为 NightlyJobs 的计划的信息。
USE msdb ;
GO
EXEC dbo.sp_help_schedule
    @schedule_name = N'NightlyJobs' ;
GO
.gif)