Partilhar via


SqlSchema Element for EventClass/Chronicles/Chronicle (ADF)

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

Syntax

<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)

Remarks

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.

Example

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>

See Also

Reference

Application Definition File Reference

Other Resources

Defining Event Chronicle Tables
Defining Chronicles for an Event Class
Updating Instances and Applications

Help and Information

Getting SQL Server 2005 Assistance