Determining When to Use Triggers

When you are creating a SQL database, you must choose whether you want to write all your table modification scripts using standard SQL, or put many of the modification routines into stored procedures. If you use stored procedures to handle these modifications and you revoke any direct permission to insert, update, and delete rows from the tables, you probably don't need to use triggers. However, if you choose not to use stored procedures, or you cannot use them due to restrictions in the database connection software you are using, triggers are the only way to get things done efficiently.

Triggers become part of the table by attaching themselves to one or more of the standard actions against that table. After you ...

Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition 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.