共用方式為


SqlExpression Element for ConditionAction (ADF)

Specifies the Transact-SQL query used to generate notifications from the input and subscription data.

語法

<ConditionAction>
    ...
    <SqlExpression>

Element Characteristics

Characteristic Description

Data type

string between 1 and 100000 characters.

Default value

None.

Occurrence

Required once per ConditionAction element.

Updates

You can modify this element, but cannot add or delete it when updating the application. You can add and delete the parent ConditionAction element.

Element Relationships

Relationship Elements

Parent element

ConditionAction Element (ADF)

Child elements

None.

備註

The SqlExpression element 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 定義條件動作.

範例

The following example shows how to define a condition action. The query in the Transact-SQL expression selects data from the MyAppSchema.WeatherEventRule view, which contains data from the subscription class and from the MyAppSchema.WeatherEvents event view.

<ConditionAction>
    <SqlLogin>[MyLowPrivLogin]</SqlLogin>
    <SqlUser>[MyLowPrivUser]</SqlUser>
    <InputName>WeatherEvents</InputName>
    <InputSchema>MyAppSchema</InputSchema>
    <SqlExpression>
        INSERT INTO MyAppSchema.WeatherNotifications(SubscriberId, 
        DeviceName, SubscriberLocale, City, Forecast) 
        SELECT [Subscription.SubscriberId], [Subscription.DeviceName], 
            [Subscription.SubscriberLocale], [Input.City], 
            [Input.Forecast])
        FROM MyAppSchema.WeatherEventRule;
    </SqlExpression>
</ConditionAction>

請參閱

參考

Application Definition File Reference

概念

Instance Configuration File Reference

其他資源

INSERT (Transact-SQL)
SELECT (Transact-SQL)
定義條件動作
定義訂閱規則

說明及資訊

取得 SQL Server 2005 協助