sp_add_notification (Transact-SQL)

設定警示通知。

語法

sp_add_notification [ @alert_name = ] 'alert' , 
    [ @operator_name = ] 'operator' , 
    [ @notification_method = ] notification_method

引數

[ @alert_name= ] 'alert'

這項通知的警示。alertsysname,沒有預設值。

[ @operator_name= ] 'operator'

發生警示時所要通知的操作員。operatorsysname,沒有預設值。

[ @notification_method= ] notification_method

用來通知操作員的方法。notification_methodtinyint,沒有預設值。notification_method 可以是利用 OR 邏輯運算子組合起來的一或多個這些值。

描述

1

電子郵件

2

呼叫器

4

net send

傳回碼值

0 (成功) 或 1 (失敗)

結果集

備註

sp_add_notification 必須從 msdb 資料庫中執行。

Microsoft SQL Server Management Studio 提供了一種簡單的圖形方式供您管理整個警示系統。建議您利用 SQL Server Management Studio 來設定您的警示基礎結構。

若要傳送通知來回應警示,您必須先設定 SQL Server Agent 來傳送郵件。如需詳細資訊,請參閱<SQL Server Agent Mail>。

如果傳送電子郵件訊息或呼叫器通知失敗,會在 SQL Server Agent 服務錯誤記錄中報告這項失敗。

權限

只有系統管理員 (sysadmin) 固定伺服器角色的成員,才能夠執行 sp_add_notification

範例

下列範例會加入指定警示 (Test Alert) 的電子郵件通知。

ms173843.note(zh-tw,SQL.90).gif附註:
這個範例假設 Test Alert 已經存在,且 François Ajenstat 是有效的操作員名稱。
USE msdb ;
GO

EXEC dbo.sp_add_notification
 @alert_name = N'Test Alert',
 @operator_name = N'François Ajenstat',
 @notification_method = 1 ;
GO

請參閱

參考

sp_delete_notification (Transact-SQL)
sp_help_notification (Transact-SQL)
sp_update_notification (Transact-SQL)
sp_add_operator (Transact-SQL)
系統預存程序 (Transact-SQL)

說明及資訊

取得 SQL Server 2005 協助