Several State and Federal contracts that I have worked on in the past have
wanted to keep track of all changes to a particular record, such as who modified
the record, what kind of modification took place, and when the record modification
occurred. I decided to solve this problem with triggers because I wanted to
capture every action that occurred on a particular table. For those unfamiliar
with triggers, a trigger is a database-event that fires when a particular action
occurs. For example, an INSERT trigger would fire when a particular database
table has a record inserted.
The Web application that needed to track all database actions was an ASP Intranet
application connected to a SQL Server 7 database, using NT Challenge/Response
authentication. There were many database tables in this application, but for
this article, we'll just examine one particular table and how I managed to track
the history for this table. Applying this technique to other database tables
is trivial.
Note: A database trigger only fires once per statement;
therefore, if you perform a mass update or mass delete then those instances
will not be recorded for each record. Keep this in mind when you develop
your own triggers.
Using Triggers to track database action history
- Introduction
- Create tables
- Create triggers
Introduction
You might also like...
About the author
SQL Server books
-
SQL Wait Stats Joes 2 Pros: SQL Performance Tuning Techniques Using Wait Statistics, Types & Queues
You learn a lot when thrown into a crisis situation, where everyone is looking to you for answers. The system is down, the CEO is pleading to you for answers as the each minute cuts the company’s bottom line. When you are in a hurry, you need some ne...
SQL Server forum discussion
-
problem with select within select
by hamidreza.hr923 (2 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
How to insert & edit unique value using store procedure
by umeshdaiya (0 replies)
-
How to troubleshoot Epson laser printer?
by daisywyatt618 (0 replies)
-
convert EMPTY fields to NULL?
by viktorcheberachko (5 replies)
SQL Server podcasts
-
Deep Fried Bytes: What is the Big Deal about Big Data?
Published 8 years ago, running time 0h39m
In this episode, Woody sits down with Andrew Brust to discuss another “big” technology for developers and IT professionals: Big Data. Woody and Andrew talk about what Big Data is, who is using it, what tools are available and finally how we has technologists can use this for our products and serv.
SQL Server jobs
-
C# .NET SQL Developer
NMQA in London, United Kingdom
200-400 per day -
Senior Software Engineer
ABX Express (M) Sdn Bhd in Petaling Jaya, Malaysia
$18,000-20,000 USD per year
Comments