NSEventFlushBatch<EventClassName> (Transact-SQL)

Closes an event batch that was opened by NSEventBeginBatchEventClassName. This stored procedure commits the event collection transaction and then marks the event batch complete. You typically use this stored procedure if you are submitting individual events using Transact-SQL. See the Remarks section for more information.


[ schema_name . ] NSEventFlushBatchEventClassName
    [ @EventBatchId = ] event_batch_ID
    [, [@EventCount = ] number_of_events]


  • [ @EventBatchId =] event_batch_ID
    Is the ID number of the event batch to commit. event_batch_ID is bigint and has no default value.
  • [ @EventCount =] number_of_events
    Is the number of events submitted for the event batch. The stored procedure obtains the default value by querying the event table.

Return Code Values

0 (success) or 1 (failure)

Result Sets

Column Name Data Type Description



Number of events submitted in the event batch. This number is either specified in the @EventCount argument or obtained by querying the events table.


Notification Services creates the NSEventFlushBatchEventClassName 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.

To use a query to obtain a set of events and then submit them to an application, use NSEventSubmitBatchEventClassName.


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


The following example shows how to begin an event batch, write one event, and then close the event batch. The event provider for the event batch is StockEP and the event batch ID number is returned in the **@BatchID** output parameter.

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

DECLARE @BatchID bigint;
EXEC dbo.NSEventBeginBatchStockEvents N'StockEP', @BatchID OUTPUT;
EXEC dbo.NSEventWriteStockEvents
EXEC dbo.NSEventFlushBatchStockEvents @BatchID;
SELECT @BatchID 'Event Batch';

This example assumes that you are using Microsoft SQL Server Management Studio because the event batch ID is returned in the SELECT statement so you can see which event batch was created.

See Also


Notification Services Stored Procedures (Transact-SQL)

Other Resources

Notification Services Performance Reports
SchemaName Element (ADF)

Help and Information

Getting SQL Server 2005 Assistance