Share via


NSEventSubmitBatch<EventClassName> (Transact-SQL)

Creates a new event batch, obtains a set of events from a query and then submits those events, optionally runs a post-processing query, and then closes the event batch. Using a query as the event source enables you to submit multiple events at one time, unlike the NSEventWriteEventClassName stored procedure.

Syntax

[ schema_name . ] SEventSubmitBatchEventClassName
    [ @ProviderName = ] 'event_provider_name',
    [ @EventsQuery = ] 'selection_query',
    [ @PostQuery = ] 'post_processing_query' 

Arguments

  • [ @ProviderName = ] 'provider_name'
    Is the name of the event provider that is submitting the events. provider_name is nvarchar(255) and must be one of the event providers specified in the application definition file (ADF).
  • [ @EventsQuery = ] 'selection_query'
    Is the text of the Transact-SQL query used to select the records to be submitted as events. The schema of the records generated by the query must match the schema of the event table to which they are being submitted. selection_query is nvarchar(4000).
  • [ @PostQuery = ] 'post_processing_query'
    Is the text of a Transact-SQL query used to do any post-processing cleanup or state maintenance, like updating chronicle tables or deleting any temporary objects. post_processing_query is nvarchar(4000).

Return Code Values

0 (success) or 1 (failure)

Result Sets

Column Name Data Type Description

EventCount

bigint

Number of events submitted in the event batch. This number is obtained by querying the event table.

Remarks

Microsoft SQL Server Notification Services creates the NSEventSubmitBatchEventClassName stored procedure in the application database when you create the instance. When you update the application, Notification Services recompiles the stored procedure.

This stored procedure is in the application's schema, which is specified by the SchemaName element of the application definition file (ADF). If no schema name is provided, the default schema is dbo.

To submit individual events to an application using Transact-SQL, use NSEventBeginBatchEventClassName to open the batch, NSEventWriteEventClassName to write individual events, and NSEventFlushBatchEventClassName to close the event batch.

Permissions

Execute permissions default to members of the NSEventProvider and NSRunService database roles, the db_owner fixed database role, and the sysadmin fixed server role.

Examples

The following example shows how to use the NSEventSubmitBatchStockEvents stored procedure to obtain stock names and prices from the Stocks table of the Market database, and then write the data to the NSStockEventsEvents table. The query specifies an empty post-processing query.

The application uses the default SchemaName settings, which places all application objects in the dbo schema.

EXEC dbo.NSEventSubmitBatchStockEvents
    @ProviderName = N'StockEP', 
    @EventsQuery = 'SELECT StockSymbol, StockPrice 
                    FROM Market.dbo.Stocks', 
    @PostQuery = '';

See Also

Reference

Notification Services Stored Procedures (Transact-SQL)

Other Resources

Notification Services Performance Reports
SchemaName Element (ADF)

Help and Information

Getting SQL Server 2005 Assistance