• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

Audit Table update via trigger

I'm trying to create an update trigger on a particular table that will fire BEFORE the update takes place. I'd like the trigger to select the values of the record that are about to be updated and insert them into another table first and THEN fire the update statement.

So, prior to updating table1-recordx, I want to insert the values of recordx into table2.

We will be using this technique as a way of auditing changes to a particular table with the ability to easily roll those changes back via a web-app front end screen.

Anyone know of a simple way to do this in SQL Server? Version is 2008 R2 if that matters.
0
dsurrett2
Asked:
dsurrett2
1 Solution
 
Scott PletcherSenior DBACommented:
You will have to use an INSTEAD OF trigger instead of an AFTER trigger.

SQL Server does not have BEFORE triggers.
0
 
dsurrett2Author Commented:
Ok, thanks. This looks like the right solution for us. Exactly what I was looking for.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now