MS SQL Basics Tutorial: INSTEAD of Triggers

Source: Internet
Author: User
Tags one table split advantage

In the fifth section of this chapter, we have noted that SQL Server 2000 supports after and instead of two types of triggers. Where the instead OF triggers is a newly added feature of SQL Server 2000, after triggers are equivalent to triggers in previous versions. When a instead type trigger for an action (INSERT, DELETE, UPDATE) is defined for a table or view and the appropriate action is performed, the trigger SQL statement itself is run, although the trigger is triggered but the corresponding action is not executed.

The main advantage of the INSTEAD of triggers is that views that cannot be modified can support modifications. Typical examples are split views (partitioned view). To improve query performance, a split view is usually a result set from more than one table, but it is also not supported for view updates. The following example shows how to use the instead OF triggers to support modifications to the base table referenced by the split view.

The INSERT statement can be successfully executed at this point insert into saleview values (' jul001 ', ' First Division VCD ', 200). Another advantage of the INSTEAD of triggers is that the rest of the execution is discarded by using a logical statement to perform a portion of the batch. For example, you can define a trigger to perform another part of the trigger when it encounters an error.

See the full set of "MS SQL Basics Tutorials"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.