Transact-SQL 参考

sp_help_notification

报告给定的操作员的警报列表,或者报告给定的警报的操作员列表。

语法

sp_help_notification [ @object_type = ] 'object_type' ,
    
[ @name = ] 'name' ,
    
[ @enum_type = ] 'enum_type' ,
    [ @notification_method = ] notification_method
    [ , [ @target_name = ] 'target_name' ]

参数

[@object_type =] 'object_type'

是将要返回的信息类型。object_type 的数据类型为 char(9),无默认值。object_type 可以为 ALERTS,这样将列出指派给所提供的操作员名称的警报;还可以为 OPERATORS,这样将列出对所提供的警报名称负责的操作员。

[@name =] 'name'

是警报名称(如果 object_type 为 ALERTS)或操作员名称(如果 object_typeOPERATORS)。name 的数据类型为 sysname,无默认值。

[@enum_type =] 'enum_type'

是返回的 object_type 信息。大多数情况下,enum_typeACTUALenum_type 的数据类型为 char(10),无默认值,并且可以是下列值之一。

描述
ACTUAL 只列出与 name 相关的 object_types
ALL 列出所有的 object_types,包括那些与 name 不相关的 object_types
TARGET 只列出那些与提供的 target_name 相匹配的 object_types,而不考虑与 name 的关联。

[@notification_method =] notification_method

是数值,而该值确定要返回的提示方法列。notification_method 的数据类型为 tinyint,并且可以是下列值之一。

描述
1 电子邮件:只返回 use_email 列。
2 寻呼机:只返回 use_pager 列。
4 NetSend:只返回 use_netsend 列。
7 全部:返回全部列。

[@target_name =] 'target_name'

是要搜索的警报名称(如果 object_typeALERTS)或者是要搜索的操作员名称(如果 object_typeOPERATORS)。只有当 enum_typeTARGET 时,才需要 target_nametarget_name 的数据类型为 sysname,默认值为 NULL。

返回代码值

0(成功)或 1(失败)

结果集

如果 object_typeALERTS,那么结果集将为给定操作员列出所有警报。

列名 数据类型 描述
alert_id int 警报标识号。
alert_name sysname 警报名称。
use_email int 使用电子邮件提示操作员:

1 = 是
0 = 否

use_pager int 使用寻呼机提示操作员:

1 = 是
0 = 否

use_netsend int 使用网络弹出消息提示操作员:

1 = 是
0 = 否

has_email int 为该警报发送的电子邮件提示的次数。
has_pager int 为该警报发送的寻呼机提示的次数。
has_netsend int 为该警报发送的 netsend 提示的次数。

如果 object_typeOPERATORS,那么结果集为给定的警报列出所有操作员。

列名 数据类型 描述
operator_id int 操作员标识号。
operator_name sysname 操作员名称。
use_email int 使用电子邮件发送操作员的提示:

1 = 是
0 = 否

use_pager int 使用寻呼机发送操作员的提示:

1 = 是
0 = 否

use_netsend int 使用网络弹出消息提示操作员:

1 = 是
0 = 否

has_email int 操作员有电子邮件地址:

1 = 是
0 = 否

has_pager int 操作员有寻呼机地址:

1 = 是
0 = 否


注释

必须从 msdb 数据库运行该存储过程。

权限

执行该过程的权限默认授予 sysadmin 固定服务器角色和 db_owner 固定数据库角色,他们可以将权限授予其他用户。

示例
A. 列出特定操作员的警报

下面的示例返回操作员 John Doe 接收到任何一种有关提示的所有警报。

USE msdb
EXEC sp_help_notification 'ALERTS', 'John Doe', 'ACTUAL', 7
B. 列出特定警报的操作员

下面的示例返回接收到有关 Test Alert 警报的任何一种提示的所有操作员。

USE msdb
EXEC sp_help_notification 'OPERATORS', 'Test Alert', 'ACTUAL', 7

请参见

sp_add_notification

sp_delete_notification

sp_update_notification

系统存储过程