sp_add_notification (Transact-SQL)

Konfiguruje powiadomienia dla alert.

Topic link iconKonwencje składni języka Transact-SQL

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

Argumenty

  • [ @alert_name= ] 'alert'
    The alert for this notification.alert is sysname, with no default.

  • [ @operator_name= ] 'operator'
    The operator to be notified when the alert occurs.operator is sysname, with no default.

  • [ @notification_method= ] notification_method
    The method by which the operator is notified.notification_method is tinyint, with no default.notification_method can be one or more of these values combined with an OR logical operator.

    Wartość

    Description

    1

    Wiadomości e-mail

    2

    Pager

    4

    polecenie net send

Wartości kodów powrotnych

0 (sukces) lub 1 (brak)

Zestawy wyników

None

Remarks

sp_add_notification musi być uruchamiane msdb bazy danych.

SQL Server Management Studio zapewnia łatwy, graficzny sposób zarządzać całym systemem alertów.Za pomocą Management Studio Zalecany sposób konfigurowania programu alert infrastruktury.

Aby wysłać powiadomienia w odpowiedzi na alert, należy najpierw skonfigurować SQL Server Agent do wysyłania poczty. Aby uzyskać więcej informacji zobaczSQL Server Agent Mail.

Jeżeli błąd wystąpi podczas wysyłania wiadomości e-mail lub pager powiadomienie, brak jest zgłaszana w SQL Server Dziennik błędów usługa agenta.

Uprawnienia

Tylko członkowie sysadmin roli serwera stałe mogą być wykonać sp_add_notification.

Przykłady

W następującym przykładzie dodano powiadomienie e-mail określonego alertu (Test Alert).

Uwaga

W tym przykładzie założono, że Test Alert już istnieje i że François Ajenstat jest nazwą prawidłową operator.

USE msdb ;
GO

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