Posts

Showing posts with the label FOR trigger

SQL Server: About the for triggers and the After triggers

Image
Hi Guys, Welcome back! After the last post about  How to read an XML file from SQL Server ,today we have only some brief notes about triggers! We talk about the for triggers and after triggers .  So, are you ready? Introduction I think we all know what is a SQL Server Trigger. A trigger is simply a procedure triggered after the execution of a Insert, Update or Delete T-SQL Command . When you write a trigger you could specify the option FOR / AFTER or INSTEAD OF. What is the difference? If you specify FOR/AFTER parameter trigger is fired when " all operations specified in the triggering SQL statement have executed successfully ". While if you specify the ISTEAD OF parameter the trigger is fired in place of the T-SQL statement. But, what is the difference between the clause FOR and the clause AFTER? For Triggers and After Triggers In order to do an example let's take our famous ORDTES table. Now define the triggers below: CREATE TRIGGER [dbo].[TR_ORDT...