SqlTriggerContext Class
Provides contextual information about the trigger that was fired.
Assembly: System.Data (in System.Data.dll)
The SqlTriggerContext type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ColumnCount | Gets the number of columns contained by the data table bound to the trigger. This property is read-only. |
![]() | EventData | Gets the event data specific to the action that fired the trigger. |
![]() | TriggerAction | Indicates what action fired the trigger. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IsUpdatedColumn | Returns true if a column was affected by an INSERT or UPDATE statement. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | 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.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.


