Previous Topic: Define SQL Server TriggersNext Topic: Define SQL Server View Triggers


Define SQL Server Table Triggers

Use the SQL Server Table Trigger Editor to define the stored procedures that exist for a table in a SQL Server 2008, 2012, 2014 or 2016 physical model.

To define SQL Server table triggers

  1. Right-click a table trigger in the Model Explorer and click Properties.

    The SQL Server Table Trigger Editor opens.

  2. Select the table from the Table drop-down that contains the table trigger that you want to define.
  3. Select the table trigger in the Navigation Grid that you want to define and work with the following options:

    Note: Click New New icon in property editors to create a new object on the toolbar to create a new table trigger. Use the Enter filter text box to filter a very large list of table triggers to quickly locate the one that you want to define.

    Name

    Displays the table trigger name. You can change the trigger name in this field.

    Schema

    Specifies the schema for the table trigger. Select a schema from the drop-down list or click the New icon to open the SQL Server Schema Editor and create one.

    Insert

    Specifies to execute the table trigger on INSERT.

    Update

    Specifies to execute the table trigger on UPDATE.

    Delete

    Specifies to execute the table trigger on DELETE.

    Trigger Timing

    Specifies when the table trigger is executed.

    Generate

    Generates SQL during forward engineering. Clear the check box if you do not want to generate SQL.

  4. Click the General tab and work with the following options:
    Trigger Type

    Specifies the code type of the trigger and its associated values. Select one of the following code types from the drop-down list:

    SQL

    Specifies to use SQL code.

    Assembly

    Specifies to use Common Language Runtime code defined in an assembly.

    NativeCompilation

    Specifies to use triggers that are compiled to native code that access memory-optimized tables. Native compilation is available SQL Server 2016 onward.

    Encryption Enabled

    Specifies that the table trigger is encrypted in the database.

    Not for replication

    Specifies that the table trigger is not invoked as part of database replication.

    Schema Binding

    Specifies that the tables that are referenced by a trigger cannot be dropped or altered.

    This option is required for triggers on memory-optimized tables and is not supported for triggers on traditional tables. Available SQL Server 2016 onward.

    Enabled State

    Specifies whether the table trigger is enabled or disabled.

    Type

    Specifies the permission level in effect when the table trigger is executed.

    Select User

    Specifies the user whose permissions are in effect for the execution of the table trigger.

    Note: This option is only available if you have selected the Execute As User option in the Type drop-down list.

    Referential Integrity Constraints

    Displays the relationships and tables associated with the table trigger.

  5. Click the Code tab to define the code type for the table trigger.
  6. Click the Expanded tab to view expanded code for the table trigger.
  7. (Optional) Click the Comment tab and enter any comments that you want to associate with the object.
  8. (Optional) Click the UDP tab to work with user-defined properties for the object.
  9. (Optional) Click the Notes tab to view and edit user notes.
  10. Click Close.

    The table trigger is defined and the SQL Server Table Trigger Editor closes.

More information:

Define the Code Type for an Object in a SQL Server Property Editor

View Expanded Code in a Property Editor

Add a Comment in a Property Editor

Add a UDP in a SQL Server Physical Property Editor