SubscriptionConditionEventRule.SqlExpression Property
Gets or sets the Transact-SQL query used to generate notifications from the input and subscription data.
Espacio de nombres: Microsoft.SqlServer.Management.Nmo
Ensamblado: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
Sintaxis
'Declaración
Public Property SqlExpression As String
public string SqlExpression { get; set; }
public:
property String^ SqlExpression {
String^ get ();
void set (String^ value);
}
/** @property */
public String get_SqlExpression ()
/** @property */
public void set_SqlExpression (String value)
public function get SqlExpression () : String
public function set SqlExpression (value : String)
Valor de propiedad
A String, between 1 and 100000 characters in length, that specifies the Transact-SQL query to run each time the rule is fired.
Notas
The SqlExpression property contains the core query for generating notifications, which selects subscription and input fields and adds them to the notification table.
The query must select subscription and input fields from a view that joins subscription and input data. Subscription fields in the view have names in the form [Subscription.SubscriptionFieldName]
. Input (event) fields have names in the form [Input.EventFieldName]
.
Subscribers create the equivalent of the WHERE clause for the query in their subscriptions through a subscription management interface. Notification Services evaluates the condition actions for all relevant subscriptions and then generates notifications.
For more information about condition actions, and a template for the Transact-SQL expression, see Definir acciones de condición.
Ejemplo
The following example shows how to define a condition-based, event-driven subscription rule and add it to a subscription class:
// Add a rule to generate condition-based, event notifications
SubscriptionConditionEventRule flightConditionEventRule =
new SubscriptionConditionEventRule(
flightSubscriptions, "FlightConditionEventRule");
flightConditionEventRule.EventClassName = "FlightEvents";
flightConditionEventRule.ActionTimeout = new TimeSpan(0, 2, 0);
flightConditionEventRule.SqlLoginName = "MyLowPrivLogin";
flightConditionEventRule.SqlUserName = "MyLowPrivUser";
flightConditionEventRule.InputTypeName = "FlightEvents";
flightConditionEventRule.InputTypeSchema = "MyAppSchema";
flightConditionEventRule.SqlExpression =
"INSERT INTO MyAppSchema.FlightNotifications (SubscriberId, " +
"DeviceName, SubscriberLocale, LeavingFrom, GoingTo, Price) " +
"SELECT [Subscription.SubscriberId], [Subscription.DeviceName], " +
"[Subscription.SubscriberLocale], " +
"[Input.LeavingFrom], [Input.GoingTo], [Input.Price] " +
"FROM MyAppSchema.FlightConditionEventRule;";
flightSubscriptions.SubscriptionConditionEventRules.Add(
flightConditionEventRule);
' Add a rule to generate condition-based, event notifications
Dim flightConditionEventRule As _
SubscriptionConditionEventRule = _
New SubscriptionConditionEventRule( _
flightSubscriptions, "FlightConditionEventRule")
flightConditionEventRule.EventClassName = "FlightEvents"
flightConditionEventRule.ActionTimeout = New TimeSpan(0, 2, 0)
flightConditionEventRule.SqlLoginName = "MyLowPrivLogin"
flightConditionEventRule.SqlUserName = "MyLowPrivUser"
flightConditionEventRule.InputTypeName = "FlightEvents"
flightConditionEventRule.InputTypeSchema = "MyAppSchema"
flightConditionEventRule.SqlExpression = _
"INSERT INTO MyAppSchema.FlightNotifications " + _
"(SubscriberId, DeviceName, SubscriberLocale, LeavingFrom, " + _
"GoingTo, Price) SELECT [Subscription.SubscriberId], " + _
"[Subscription.DeviceName], [Subscription.SubscriberLocale], " + _
"[Input.LeavingFrom], [Input.GoingTo], [Input.Price] " + _
"FROM MyAppSchema.FlightConditionEventRule;"
flightSubscriptions.SubscriptionConditionEventRules.Add( _
flightConditionEventRule)
Seguridad para subprocesos
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Plataformas
Plataformas de desarrollo
Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.
Plataformas de destino
Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.
Vea también
Referencia
SubscriptionConditionEventRule Class
SubscriptionConditionEventRule Members
Microsoft.SqlServer.Management.Nmo Namespace
Otros recursos
SqlExpression Element for ConditionAction (ADF)
Definir reglas de evento
Definir acciones de condición
EventRule Element (ADF)
ConditionAction Element (ADF)