Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
Provides context information for event handlers.
EVENT_PARAMETER( context-name )
context-name One of the preset strings. The strings are case insensitive, and carry the following information:
AppInfo The value of the AppInfo connection property for the connection that caused the event to be triggered. You can see the value of the property from outside of the context of the event by using the following statement:
SELECT connection_property( 'AppInfo' );
This parameter is valid for Connect, Disconnect, ConnectFailed, BackupEnd, and RAISERROR events. The AppInfo string contains the machine name and application name of the client connection for embedded SQL, ODBC, OLE DB, ADO.NET, and iAnywhere JDBC driver connections.
ConnectionId The connection ID of the connection that caused the event to be triggered.
DisconnectReason A string indicating the reason the connect was terminated. This parameter is valid only for Disconnect events. Possible results include:
from client The client application disconnected.
drop connection A DROP CONNECTION statement was executed.
liveness No liveness packets were received for the period specified by the -tl server option.
inactive No requests were received for the period specified by the -ti server option.
connect failed A connection attempt failed.
EventName The name of the event that has been triggered.
Executions The number of times the event handler has been executed.
MirrorServerName The name of the mirror or arbiter server that lost its connection to the primary server in a database mirroring system.
NumActive The number of active instances of an event handler. This is useful if you want to limit an event handler so that only one instance executes at any given time.
ScheduleName The name of the schedule which caused an event to be fired. If the event was fired manually using TRIGGER EVENT or as a system event, the result will be an empty string. If the schedule was not assigned a name explicitly when it was created, its name will be the name of the event.
TableName The name of the table, for use with RemainingValues.
User The user ID for the user that caused the event to be triggered.
In addition, you can access any of the valid condition-name arguments to the EVENT_CONDITION function from the EVENT_PARAMETER function.
The following table indicates which context-name values are valid for which system event types.
|Context-name value||Valid system event types|
|AppInfo||BackupEnd, "Connect", ConnectFailed, "Disconnect", "RAISERROR", user events|
|ConnectionID||BackupEnd, "Connect", "Disconnect", Global Autoincrement, "RAISERROR", user events|
|User||BackupEnd, "Connect", ConnectFailed, "Disconnect", GlobalAutoincrement, "RAISERROR", user events|
SQL/2003 Vendor extension.
The following example shows how to pass a string parameter to an event. The event displays the time it was triggered on the server console.
CREATE EVENT ev_PassedParameter HANDLER BEGIN MESSAGE 'ev_PassedParameter - was triggered at ' || event_parameter( 'time' ); END; TRIGGER EVENT ev_PassedParameter( "Time"=string(current timestamp ) );