APPENDIX B

image

DML Trigger Basics and Templates

In this appendix, I briefly introduce triggers and how they are written and present templates that you can use as the basis for creating DML triggers for all sorts of uses. There are two different types of DML triggers that are coded very similarly, but serve different purposes:

  • The AFTER trigger is made to be called after an INSERT, UPDATE, or a DELETE, and the constraints it references, is called. It is used to apply complex checks and to add side effects to a DML operation as may be needed. AFTER triggers are usually used for handling rules that won’t fit into the mold of a constraint, for ...

Get Pro SQL Server 2012 Relational Database Design and Implementation now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.