更新現(xiàn)有警報(bào)的設(shè)置。
sp_updatealert [@name =] 'name'
[, [@new_name =] 'new_name']
[, [@message_id =] message_id]
[, [@enabled =] enabled]
[, [@severity =] severity]
[, [@delay_between_responses =] delay_between_responses]
[, [@notification_message =] 'notification_message']
[, [@include_event_description_in =] include_event_description_in]
[, [@database_name =] 'database_name']
[, [@event_description_keyword =] 'event_description_keyword']
[, [@job_id =] job_id | [@job_name =] 'job_name']
[, [@occurrence_count = ] occurrence_count]
[, [@count_reset_date =] count_reset_date]
[, [@count_reset_time =] count_reset_time]
[, [@last_occurrence_date =] last_occurrence_date]
[, [@last_occurrence_time =] last_occurrence_time]
[, [@last_response_date =] last_response_date]
[, [@last_response_time =] last_response _time]
[, [@raise_snmp_trap =] raise_snmp_trap]
[, [@performance_condition =] 'performance_condition']
[, [@category_name =] 'category']
[@name =] 'name'
是要更新的警報(bào)的名稱。name 的數(shù)據(jù)類型為 sysname,無默認(rèn)值。
[@new_name =] 'new_name'
是警報(bào)的新名稱。該名稱必須是唯一的。new_name 的數(shù)據(jù)類型為 sysname,其默認(rèn)值為 NULL。
[@enabled =] enabled
指定警報(bào)啟用 (1) 或不啟用 (0)。enabled 的數(shù)據(jù)類型為 tinyint,其默認(rèn)值為 NULL。警報(bào)必須啟用后才能激發(fā)。
[@message_id =] message_id
是警報(bào)定義的新消息編號(hào)或錯(cuò)誤號(hào)。message_id 通常對(duì)應(yīng)于表 sysmessages 中的某一錯(cuò)誤號(hào)。message_id 的數(shù)據(jù)類型為 int,其默認(rèn)值為 NULL。僅當(dāng)該警報(bào)的嚴(yán)重級(jí)別設(shè)置為 0 時(shí)才能使用消息 ID。
[@severity =] severity
是警報(bào)定義的新嚴(yán)重級(jí)別(從 1 至 25)。任何以指定嚴(yán)重度發(fā)送到 Windows NT® 應(yīng)用程序日志的 Microsoft® SQL Server™ 消息都將激活該警報(bào)。severity 的數(shù)據(jù)類型為 int,默認(rèn)設(shè)置為 NULL。僅當(dāng)該警報(bào)的消息 ID 設(shè)置為 0 時(shí),才能使用嚴(yán)重級(jí)別。
[@delay_between_responses =] delay_between_responses
是對(duì)警報(bào)的各響應(yīng)之間的新等待時(shí)間(以秒計(jì))。delay_between_responses 的數(shù)據(jù)類型為 int,其默認(rèn)值為 NULL。
[@notification_message =] 'notification_message'
是修正過的附加消息文本,而該消息作為電子郵件、net send(網(wǎng)絡(luò)發(fā)送)或呼叫提示的一部分發(fā)送給操作員。notification_message 的數(shù)據(jù)類型為 nvarchar(512),默認(rèn)設(shè)置為 NULL。
[@include_event_description_in =] include_event_description_in
確定來自 Windows NT 應(yīng)用程序日志的 SQL Server 錯(cuò)誤的描述是否應(yīng)包含在提示消息中。include_event_description_in 的數(shù)據(jù)類型為 tinyint,其默認(rèn)值為 NULL,并可以取下列值中的一個(gè)或多個(gè)值。
值 | 描述 |
---|---|
0 | 無 |
1 | 電子郵件 |
2 | 呼叫程序 |
4 | net send |
[@database_name =] 'database_name'
是數(shù)據(jù)庫名。只有在該數(shù)據(jù)庫中發(fā)生錯(cuò)誤時(shí),才能激發(fā)警報(bào)。database_name 的數(shù)據(jù)類型為 sysname,其默認(rèn)值為 NULL。
[@event_description_keyword =] 'event_description_keyword'
是錯(cuò)誤信息日志的錯(cuò)誤描述中必須包含的字符序列??梢允褂?Transact-SQL LIKE 表達(dá)式的模式匹配字符。event_description_keyword 的數(shù)據(jù)類型為 nvarchar(100),其默認(rèn)值為 NULL。該參數(shù)在篩選對(duì)象名稱(例如,%customer_table%)時(shí)很有用。
[@job_id =] job_id
作業(yè)標(biāo)識(shí)號(hào)。job_id 的數(shù)據(jù)類型為 uniqueidentifier,默認(rèn)值為 NULL。如果指定了 job_id,就必須省略 job_name。
[@job_name =] 'job_name'
是響應(yīng)該警報(bào)而執(zhí)行的作業(yè)的名稱。job_name 的數(shù)據(jù)類型為 sysname,其默認(rèn)值為 NULL。如果指定了 job_name,就必須省略 job_id。
[@occurrence_count = ] occurrence_count
重置警報(bào)發(fā)生的次數(shù)。occurrence_count 的數(shù)據(jù)類型為 int,其默認(rèn)值為 NULL,且只能設(shè)置為 0。
[@count_reset_date =] count_reset_date
重置發(fā)生計(jì)數(shù)的上一次重置日期。count_reset_date 的數(shù)據(jù)類型為 int,其默認(rèn)值為 NULL。
[@count_reset_time =] count_reset_time
重置發(fā)生計(jì)數(shù)的上一次重置時(shí)間。count_reset_time 的數(shù)據(jù)類型為 int,其默認(rèn)值為 NULL。
[@last_occurrence_date =] last_occurrence_date
重置警報(bào)的上一次發(fā)生日期。last_occurrence_date 的數(shù)據(jù)類型為 int,其默認(rèn)值為 NULL,且只能設(shè)置為 0。
[@last_occurrence_time =] last_occurrence_time
重置警報(bào)的上一次發(fā)生時(shí)間。last_occurrence_time 的數(shù)據(jù)類型為 int,其默認(rèn)值為 NULL,且只能設(shè)置為 0。
[@last_response_date =] last_response_date
重置 SQLServerAgent 服務(wù)上一次響應(yīng)警報(bào)的日期。last_response_date 的數(shù)據(jù)類型為 int,其默認(rèn)值為 NULL,且只能設(shè)置為 0。
[@last_response_time =] last_response_time
重置 SQLServerAgent 服務(wù)上一次響應(yīng)警報(bào)的時(shí)間。last_response_time 的數(shù)據(jù)類型為 int,其默認(rèn)值為 NULL,且只能設(shè)置為 0。
[@raise_snmp_trap =] raise_snmp_trap
保留。
[@performance_condition =] 'performance_condition'
是以 'item comparator value' 格式表示的值。performance_condition 的數(shù)據(jù)類型為 nvarchar(512),其默認(rèn)值為 NULL,并含有以下元素。
格式元素 | 描述 |
---|---|
item | 性能對(duì)象,性能計(jì)數(shù)器或計(jì)數(shù)器的命名實(shí)例 |
Comparator | 下列運(yùn)算符之一: >, <, = |
Value | 計(jì)數(shù)器的數(shù)值 |
[@category_name =] 'category'
警報(bào)分類的名稱。category 的數(shù)據(jù)類型為 sysname,默認(rèn)值為 NULL。
0(成功)或 1(失?。?/P>
sp_update_alert 必須從 msdb 數(shù)據(jù)庫中執(zhí)行。
只有寫入 Microsoft® Windows NT® 應(yīng)用程序日志的 sysmessages 才能激發(fā)警報(bào)。
sp_update_alert 只更改提供了參數(shù)值的警報(bào)設(shè)置。如果省略某一參數(shù),則保留其當(dāng)前設(shè)置。
只有 sysadmin 固定服務(wù)器角色的成員才能執(zhí)行 sp_update_alert。
下例將 Test Alert 的 enabled 設(shè)置更改為 0。
sp_updatealert @name = 'Test Alert', @enabled = 0
相關(guān)文章