O'Reilly logo

Microsoft SQL Server 2014 Unleashed by Paul Bertucci, Alex T. Silverstein, Chris Gallelli, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

INSTEAD OF Triggers

An INSTEAD OF trigger, like its name implies, performs its actions instead of the action that fired it. This is much different from the AFTER trigger, which performs its actions after the statement that caused it to fire has completed. This means you can have an INSTEAD OF update trigger on a table that successfully completes but does NOT include the actual update to the table.

The basic syntax for creating an INSTEAD OF trigger is as follows:

CREATE TRIGGER trigger_nameON table_nameINSTEAD OF { INSERT | UPDATE | DELETE }ASSQL statements

Listing 27.5 shows how to create a trigger that prints a message stating the number of rows to be updated by an UPDATE statement but it completes without performing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required