SqlTriggerContext Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Provides contextual information about the trigger that was fired.

Namespace:   Microsoft.SqlServer.Server
Assembly:  System.Data (in System.Data.dll)


public ref class SqlTriggerContext sealed 


Gets the number of columns contained by the data table bound to the trigger. This property is read-only.


Gets the event data specific to the action that fired the trigger.


Indicates what action fired the trigger.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Returns true if a column was affected by an INSERT or UPDATE statement.


Returns a string that represents the current object.(Inherited from Object.)

The contextual information provided includes the type of action that caused the trigger to fire, which columns were modified in an UPDATE operation, and, in the case of a data definition language (DDL) trigger, an XML EventData structure (see "Transact-SQL Reference" in SQL Server Books Online) that describes the triggering operation.

An instance of SqlTriggerContext is available from the SqlContext class, when the code is running inside a trigger through the TriggerContext property.

The following example shows a SqlTriggerContext object being used to determine if an Insert action occurred. If a row was inserted into the user's table, the user name and real name are retrieved from the inserted row and then added to the UserNameAudit table.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top