Transact-SQL 参考

sp_help_alert

报告有关为服务器定义的警报的信息。

语法

sp_help_alert [ [ @alert_name = ] 'alert_name' ]
    
[ , [ @order_by = ] 'order_by' ]
    
[ , [ @alert_id = ] alert_id ]
    [ , [ @category_name = ] 'category' ]

参数

[@alert_name =] 'alert'

是警报名称。alert_name 的数据类型为 nvarchar(128)。如果没有指定 alert_name,那么将返回有关所有警报的信息。

[@order_by =] 'order_by'

是用于生成结果的排序次序。order_by 的数据类型为 sysname,默认值为 N 'name'。

[@alert_id =] alert_id]

是用于报告有关信息的警报标识号。alert_id 的数据类型为 int,默认值为 NULL。

[@category_name =] 'category'

是警报的分类。category 的数据类型为 sysname,默认值为 NULL。

返回代码值

0(成功)或 1(失败)

结果集
列名 数据类型 描述
id int 系统指派的唯一整数标识符。
name sysname 警报名称(例如 Demo:Full msdb log)。
event_source nvarchar(100) 事件源。对于 Microsoft® SQL Server™ 7.0 版,事件源始终为 MSSQLServer。
event_category_id int 保留。
event_id int 保留。
message_id int 定义警报的消息错误号。(通常对应于 sysmessages 表中的错误号)。如果使用了严重度来定义警报,则 message_id 为 0 或 NULL。
severity int 定义警报的严重度级别(从 9 到 25、110、120、130 或 140)。
enabled tinyint 当前警报的状态是已启用 (1) 还是未启用 (0)。不发送未启用警报。
delay_between_responses int 响应的等待期间(以秒为单位)。
last_occurrence_date int 上次出现警报的日期。
last_occurrence_time int 上次出现警报的时间。
last_response_date int SQLServerAgent 服务上次响应警报的日期。
last_response_time int SQLServerAgent 服务上次响应警报的时间。
notification_message nvarchar(512) 发送给操作员作为电子邮件或寻呼机提示部分的可选的其它消息。
include_event_description tinyint Microsoft Windows NT® 应用程序日志中对 SQL Server 错误的描述是否应成为通知消息的一部分。
database_name sysname 必须出现错误才能使警报得以激发的数据库。如果数据库名为 NULL,那么无论是否出现错误都激发警报。
event_description_keyword nvarchar(100) Windows NT 应用程序日志中的 SQL Server 错误的描述,该错误描述必须类似于所提供的字符次序。
occurrence_count int 警报出现的次数。
count_reset_date int 上次重置 occurrence_count 的日期。
count_reset_time int 上次重置 occurrence_count 的时间。
job_id uniqueidentifier 作业标识号。
job_name sysname 响应警报而执行的按需作业。
has_notification int 如果将这个警报通知给一个或多个操作员,则为非零。该值是下列值中的一个或多个(用 OR 连起来):

1= 有电子邮件通知
2= 有呼叫提示
4= 有网络发送通知。

Flags int 保留。
performance_condition nvarchar(512) 如果 type 2,那么此列将显示性能条件的定义。否则此列为 NULL。
category_name sysname 保留。对于 SQL Server 7.0 始终是"[Uncategorized]"。
type int 1 = SQL Server 事件警报
2 = SQL Server 性能警报

注释

必须从 msdb 数据库执行 sp_help_alert

权限

只有 sysadmin 固定服务器角色的成员才可以执行 sp_help_alert

示例

下面的示例报告有关 Demo:Sev.25 Errors 警报的信息。

EXEC sp_help_alert 'Demo: Sev. 25 Errors'

请参见

sp_add_alert

sp_update_alert

系统存储过程