Skip to main content

How do I create a BEFORE trigger on a table still have the AFTER trigger working? 

I just noticed there is only the INSTEAD OF and AFTER trigger, can we create a BEFORE trigger with the SF?

Hi Freddy,

To my knowledge, SQL Server does not have Before triggers. You can write an Instead-of-trigger that first does the queries that you would like to put in the before trigger, thereafter do the actual operation, f.e. Inserting the data, and lastly run the queries that are now part of the After trigger.

Some more information I found here: https://databasefaqs.com/sql-server-trigger-before-insert/

Does that help?


Hi Freddy,

To my knowledge, SQL Server does not have Before triggers. You can write an Instead-of-trigger that first does the queries that you would like to put in the before trigger, thereafter do the actual operation, f.e. Inserting the data, and lastly run the queries that are now part of the After trigger.

Some more information I found here: https://databasefaqs.com/sql-server-trigger-before-insert/

Does that help?

 

Yes, I am mistaken. On DB2 it does have a before, on SQL Server it's the instead of trigger that completely replaces the (after) trigger on SQL server. 

I am up to date again :)