In the above section we discuss the pros and cons of triggers, how they work, and how to create triggers. Next we will elaborate on the application of triggers of varying degrees of complexity.
Application of 12.9.1 Insert-type Trigger
Application of 12.9.1 Insert-type Trigger
There are two types of newer triggers: Newer triggers in common sense and newer triggers for checking column changes, mainly because update operations can involve data items.
More new triggers in the usual sense;
As we mentioned earlier, the update operation consists of two parts, first removing the content that needs to be updated from the table, and inserting the new value. As a result, newer triggers involve deleting tables. and insert the table below the combination of specific examples to discuss it.
In some updates, the updated content is not an entire record, but only a column or columns, and a newer trigger for checking column changes is used. It differs from the usual trigger in the sense that it includes the following reserved words:
In the part of creating a trigger with the Transaction_sql Create TRIGGER command We have given the specific meaning of the reserved word. Below we will give two examples, these two examples are used in the If UPDATE (column) and if (columns_updated () respectively.
Note: You must first delete the relationships with the primary foreign key that the table title has established before the trigger can be triggered.
12.9.4 nested triggers
When a trigger executes, it can trigger another trigger, which is called a trigger nesting. Triggers can be nested to 32 levels in MS SQL Server. If you do not need nested triggers, you can set them by using the sp_configure option.
During execution, if a trigger modifies a table, and the table already has other triggers, it is necessary to use nested triggers.
Note: The primary foreign key relationships that have been established with the sales table must be deleted before triggers can be triggered.
See the full set of "MS SQL Basics Tutorials"