共用方式為


SqlSchema Element for EventClass/Chronicles/Chronicle (ADF)

Contains the Transact-SQL statements that define an event chronicle table.

語法

<EventClasses>
    <EventClass>
        ...
        <Chronicles>
            <Chronicle>
                ...
                <SqlSchema>

Element Characteristics

Characteristic Description

Data type and length

None.

Default value

None.

Occurrence

Required once per Chronicle element.

Updates

Cannot be added or deleted.

Element Relationships

Relationship Elements

Parent element

Chronicle Element for EventClass/Chronicles (ADF)

Child elements

SqlStatement Element for EventClass/Chronicles/Chronicle/SqlSchema (ADF)

備註

A SqlSchema element contains SqlStatement elements, which define batches of Transact-SQL statements. To define multiple chronicles for the event class, use multiple SqlStatement elements.

When you define an event chronicle, add code to drop, rename, or skip creating the chronicle if the table already exists. If the table exists when Notification Services attempts to update the application, you will receive an "object exists" error and the update will fail.

When creating chronicles, make sure to use the schema defined for the application database. If no schema is defined, the default schema is dbo.

範例

The following example shows how to drop an existing event chronicle table named dbo.StockEventChron, and then re-create the event chronicle table. The table contains two columns, StockSymbol and StockPrice.

<SqlSchema>
    <SqlStatement>
    IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES
        WHERE TABLE_NAME = 'StockEventsChron'
            AND TABLE_SCHEMA = 'dbo')
        DROP TABLE dbo.StockEventsChron;
    </SqlStatement>
    <SqlStatement>
    CREATE TABLE dbo.StockEventsChron
    (
    StockSymbol char(10),
    StockHighPrice money
    PRIMARY KEY (StockSymbol)
    );
    </SqlStatement>
</SqlSchema>

The following example shows how to create the event chronicle table only if a table named dbo.StockEventChron does not exist.

<SqlSchema>
    <SqlStatement>
    IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES
        WHERE TABLE_NAME = 'StockEventsChron'
            AND TABLE_SCHEMA = 'dbo')
        CREATE TABLE dbo.StockEventsChron
        (
        StockSymbolOne char(10),
        StockHighPrice money
        PRIMARY KEY (StockSymbolOne)
       );
    </SqlStatement>
</SqlSchema>

請參閱

參考

Application Definition File Reference

其他資源

定義事件紀事輯資料表
定義事件類別的紀事輯
更新執行個體及應用程式

說明及資訊

取得 SQL Server 2005 協助