5.8. Triggers for Data Integrity

Although there's a whole chapter coming up on triggers (Chapter 13), any discussion of constraints, rules, and defaults would not be complete without at least a mention of triggers.

One of the most common uses of triggers is to implement data integrity rules. Because you have that chapter coming up, I'm not going to get into it very deep here other than to say that triggers can do many things data-integrity-wise that a constraint or rule could never hope to do. The downside (and you knew there had to be one) is that they incur substantial additional overhead and are, therefore, much (very much) slower in almost any circumstance. They are procedural in nature, which is where they get their power, but they also happen after everything else is done, and should be used only as a last resort.

Get Professional SQL Server™ 2005 Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.