Calling Stored Procedures

A good way of modularizing your trigger code and cutting down on redundancy is to place the code shared in common by multiple triggers into a stored procedure and call the stored procedure from the triggers. The problem with this is that the inserted and deleted logical tables aren't available from a stored procedure. However, remember that from the perspective of an AFTER trigger, the modifications that fired it appear to have already taken place. This is also true of any code the trigger calls, including stored procedures. So, stored procedures called by the trigger do indeed have access to the data in the inserted and deleted tables by way of the table itself. The trigger can pass them the information they need to ...

Get Guru's Guide to SQL Server™ Stored Procedures, XML, and HTML, The 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.