Export (0) Print
Expand All
Expand Minimize

NSEventWrite<EventClassName> (Transact-SQL)

SQL Server 2005

Submits one event to the events table for the event class. You must use NSEventBeginBatchEventClassName to open a new batch and NSEventFlushBatchEventClassName to close the batch. You can submit multiple events before closing the batch.

[ schema_name . ] NSEventWriteEventClassName
    [ @EventBatchId = ] event_batch_ID ,
    [ @event_class_field_name = ] event_class_field_value [, ...n]

[ @EventBatchId = ] event_ batch_ID

Is the ID of the event batch for the event. The event batch ID number must exist in the event batches table. event_batch_ID is bigint and has no default value.

[ @event_class_field_name = ] event_class_field_value

Provides a name/value pair for an event class field. One event_class_field_name and event_class_field_value pair can be supplied for each column in the event table. If the column has a default value or accepts NULL, the name/value pair is not required.

0 (success) or 1 (failure)

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



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


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.


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 SQL Server Management Studio, because the event batch ID is returned in the SELECT statement so you can see which event batch was created.

Community Additions

© 2015 Microsoft