3

A DB Audit Trail captures the User Last Modified, Modified Date, and Created Date.

There are several possible implementations:

  • SQL Server Triggers
  • Add UserModified, ModifiedDate, CreatedDate columns to the database and include logic in Stored Procedures or Insert, Update statements accordingly.

It would be nice if you include implementation (or link to) in your answer.

1
  • You might want to check out <a href="in.relation.to/1236.lace">this article</a> by Hibernate developer Christian Bauer. Commented Sep 14, 2008 at 0:26

4 Answers 4

6

Depending on what you're doing, you might want to move the audit out of the data layer into the data access layer. It give you more control.

I asked a similar question wrt NHibernate and SqlServer here.

Sign up to request clarification or add additional context in comments.

Comments

1

I totally second @IainMH (and voted him up).

You want to have it in your DAL and ideally tied to some kind of aspect/interceptor/code injection mechanism.

Comments

1

+2 for implementation of when/how to audit in the DAL.

As for where the audit entries themselves should live, it depends on how it will be visible. I'd do a separate table if users can view a separate "audit trail report," but tag existing tables if you want to display last modified-type audits inline.

Comments

0

Here is the implementation I use to audit tables: Pop Rivett's SQL Server FAQ No.5: Pop on the Audit Trail

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.