Solved

BEFORE trigger

  • 23 November 2022
  • 2 replies
  • 28 views

Userlevel 4
Badge +5
  • Thinkwise Local Partner Brasil
  • 191 replies

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?

icon

Best answer by Mark Jongeling 23 November 2022, 20:42

View original

2 replies

Userlevel 7
Badge +19

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?

Userlevel 4
Badge +5

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 :)

Reply