sp_help_category (Transact-SQL)sp_help_category (Transact-SQL)

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions)

提供有关作业、警报或操作员的指定类的信息。Provides information about the specified classes of jobs, alerts, or operators.

主题链接图标 Transact-SQL 语法约定Topic link icon Transact-SQL Syntax Conventions

语法Syntax

  
sp_help_category [ [ @class = ] 'class' ]   
     [ , [ @type = ] 'type' ]   
     [ , [ @name = ] 'name' ]   
     [ , [ @suffix = ] suffix ]   

参数Arguments

[ @class = ] 'class' 要请求其信息的类。[ @class = ] 'class' The class about which information is requested. varchar (8),默认值为 JOBclass is varchar(8), with a default value of JOB. 可以是下列值之一。class can be one of these values.

Value 说明Description
任务JOB 提供有关作业类别的信息。Provides information about a job category.
发出ALERT 提供有关警报类别的信息。Provides information about an alert category.
操作员OPERATOR 提供有关操作员类别的信息。Provides information about an operator category.

[ @type = ] 'type' 请求其信息的类别的类型。[ @type = ] 'type' The type of category for which information is requested. 类型varchar (12),默认值为 NULL,可以是下列值之一。type is varchar(12), with a default of NULL, and can be one of these values.

Value 说明Description
LOCALLOCAL 本地作业类别。Local job category.
MULTI-SERVERMULTI -SERVER 多服务器作业类别。Multiserver job category.
NONENONE 作业 之外的类的类别。Category for a class other than JOB.

[ @name = ] 'name' 请求其信息的类别的名称。[ @name = ] 'name' The name of the category for which information is requested. 名称sysname,默认值为 NULL。name is sysname, with a default of NULL.

[ @suffix = ] suffix 指定结果集中 category_type 列是 ID 还是名称。[ @suffix = ] suffix Specifies whether the category_type column in the result set is an ID or a name. 后缀bit,默认值为 0suffix is bit, with a default of 0. 1category_type 显示为名称, 0 将其显示为 ID。1 shows the category_type as a name, and 0 shows it as an ID.

返回代码值Return Code Values

0 (成功) 或 1 (失败) 0 (success) or 1 (failure)

结果集Result Sets

@ 后缀0 时, sp_help_category 将返回以下结果集:When @suffix is 0, sp_help_category returns the following result set:

列名称Column name 数据类型Data type 说明Description
category_idcategory_id intint 类别 IDCategory ID
category_typecategory_type tinyinttinyint 类别的类型:Type of category:

1 = 本地1 = Local

2 = 多服务器2 = Multiserver

3 = 无3 = None
namename sysnamesysname 类别名称Category name

@ 后缀1 时, sp_help_category 将返回以下结果集:When @suffix is 1, sp_help_category returns the following result set:

列名称Column name 数据类型Data type 说明Description
category_idcategory_id intint 类别 IDCategory ID
category_typecategory_type sysnamesysname 类别的类型。Type of category. 本地多服务器One of LOCAL, MULTI-SERVER, or NONE
namename sysnamesysname 类别名称Category name

备注Remarks

必须从 msdb 数据库运行 sp_help_categorysp_help_category must be run from the msdb database.

如果未指定参数,则结果集将提供有关所有作业类别的信息。If no parameters are specified, the result set provides information about all of the job categories.

权限Permissions

默认情况下,只有 sysadmin 固定服务器角色的成员才可以执行此存储过程。By default, members of the sysadmin fixed server role can execute this stored procedure. 其他用户必须被授予 SQL ServerSQL Server msdb 数据库中下列 代理固定数据库角色的权限之一:Other users must be granted one of the following SQL ServerSQL Server Agent fixed database roles in the msdb database:

  • SQLAgentUserRoleSQLAgentUserRole

  • SQLAgentReaderRoleSQLAgentReaderRole

  • SQLAgentOperatorRoleSQLAgentOperatorRole

有关这些角色的权限的详细信息,请参阅 SQL Server 代理固定数据库角色For details about the permissions of these roles, see SQL Server Agent Fixed Database Roles.

示例Examples

A.A. 返回本地作业信息Returning local job information

以下示例将返回有关在本地管理的作业的信息。The following example returns information about jobs that are administered locally.

USE msdb ;  
GO  
  
EXEC dbo.sp_help_category  
    @type = N'LOCAL' ;  
GO  

B.B. 返回警报信息Returning alert information

以下示例将返回有关 Replication 警报类别的信息。The following example returns information about the Replication alert category.

USE msdb ;  
GO  
  
EXEC dbo.sp_help_category  
    @class = N'ALERT',  
    @name = N'Replication' ;  
GO  

另请参阅See Also

sp_add_category (Transact-sql) sp_add_category (Transact-SQL)
sp_delete_category (Transact-sql) sp_delete_category (Transact-SQL)
sp_update_category (Transact-sql) sp_update_category (Transact-SQL)
系统存储过程 (Transact-SQL)System Stored Procedures (Transact-SQL)