更新警报设置 本节介绍了更新警报设置的相关内容。 操作场景 使用存储过程更新现有警报的设置。 前提条件 成功连接RDS for SQL Server实例。通过SQL Server客户端连接目标实例。成功连接RDS for SQL Server实例。 操作步骤 执行以下命令,更新现有警报的设置。 EXEC [msdb].[dbo].[rdsupdatealert] @name'name', @newname 'newname', @messageidmessageid, @severityseverity, @enabledenabled, @delaybetweenresponses delaybetweenresponses, @notificationmessage'notificationmessage', @includeeventdescriptioninincludeeventdescriptionin, @databasename'database', @eventdescriptionkeyword 'eventdescriptionkeyword', @jobidjobid @jobname'jobname', @occurrencecount occurrencecount, @countresetdate countresetdate, @countresettime countresettime, @lastoccurrencedate lastoccurrencedate, @ lastoccurrencetime lastoccurrencetime, @ lastresponsedate lastresponsedate, @ lastresponsetime lastresponsetime, @ raisesnmptrap raisesnmptrap, @ performancecondition 'performancecondition', @categoryname'category', @wminamespace'wminamespace', @wmiquery'wmiquery'; 表 参数说明 参数 说明 'name' 更新的警报名称。名称为sysname,无默认值。 'newname' 警报新名称。该名称必须唯一。“newname”的值为“sysname”,默认值为NULL。 messageid 警报定义的新消息或错误号。通常messageid与sysmessages表中的错误号相对应。messageid的数据类型为int,默认值为NULL。仅当警报的严重级别设置为0时,才能使用消息ID。 severity 警报定义的新严重级别 (从1到25)。发送Microsoft到具有指定严重性的Windows应用程序日志的任何SQL Server消息都将激活警报。严重性为int,默认值为NULL。仅当警报的消息ID设置为0时,才能使用严重性级别。 enabled 指示警报的当前状态。enabled为tinyint,默认值为1(已启用)。 如果为0,则不启用警报,也不触发警报。 delaybetweenresponses 警报响应之间的等待时间(以秒为单位)。“delaybetweenresponses”的值为“int”,默认值为0,这意味着响应之间不等待(每次出现警报时都生成响应)。响应可以为下面的一种或两种形式: 通过电子邮件或寻呼发送的一个或多个通知。 要执行的作业。 例如,当警报在短时间内重复产生时,通过设置该值就有可能避免发送重复的电子邮件。 'notificationmessage' 作为电子邮件、net send或寻呼通知的一部分发送给操作员的可选附加消息。“notificationmessage”的值为“nvarchar(512)”,默认值为NULL。指定notificationmessage可用于添加特别注释,如补救过程。 includeeventdescriptionin 指定是否应该在通知消息SQL Server中包含Windows应用程序日志中的错误说明。其数据值为tinyint,默认值为NULL,可以是下列值中的一个或多个。 值为0,表示无。 值为1,电子邮件。 值为2,表示寻呼程序。 值为4,表示net send。 值为7,表示All。 'database' 必须发生错误才能触发警报的数据库。如果未提供数据库,则会触发警报,而不考虑错误发生的位置。数据库为sysname。不允许用方括号 ([ ]) 将名称括起来。默认值为NULL。 'eventdescriptionkeyword' 必须在错误消息日志中的错误说明中找到的字符序列。可以使用TransactSQL LIKE表达式模式匹配字符。“eventdescriptionkeyword”的值为“nvarchar (100) ”,默认值为NULL。此参数适用于筛选对象名称 (例如, % customertable% )。 jobid 作业标识号。“jobid”的值为“uniqueidentifier”, 默认值为NULL。如果指定了jobid , 则必须省略jobname。 'jobname' 为响应此警报而执行的作业的名称。“jobname”的值为“sysname”,默认值为NULL。如果指定了jobname,则必须省略jobid。 occurrencecount 重置警报发生的次数。“occurrencecount”的值为“int”,默认值为NULL,且只能设置为0。 countresetdate 重置上一次重置发生计数的日期。“countresetdate”的值为“int”,默认值为NULL。 countresettime 重置上一次重置发生计数的时间。“countresettime”的值为“int”,默认值为NULL。 lastoccurrencedate 重置警报上一次发生的日期。“lastoccurrencedate”的值为“int”,默认值为NULL,且只能设置为0。 lastoccurrencetime 重置警报上一次发生的时间。“lastoccurrencetime”的值为“int”,默认值为NULL,且只能设置为0。 lastresponsedate 重置SQLServerAgent服务上一次响应警报的日期。“lastresponsedate”的值为“int”,默认值为NULL,且只能设置为0。 lastresponsetime 重置SQLServerAgent服务上一次响应警报的时间。“lastresponsetime”的值为“int”,默认值为NULL,且只能设置为0。 raisesnmptrap 保护。 'performancecondition' 以 "itemcomparatorvalue" 格式表示的值。“performancecondition”的默认值为“nvarchar(512)”,默认值为NULL。其中包含这些元素: 格式元素为项,表示性能对象、性能计数器或计数器的命名实例。 格式元素为Comparator,表示以下运算符之一: >、< 或 。 格式元素为ReplTest1,表示计数器的数值。 'category' 警报类别的名称。category的类型为sysname,默认值为NULL。 'wminamespace' 要查询事件的WMI命名空间。“wminamespace”的值为“sysname”,默认值为NULL。 'wmiquery' 指定警报的WMI事件的查询。“wmiquery”的值为“nvarchar(512)”,默认值为NULL。 执行成功后,系统将会如下提示: plaintext Commands completed successfully.