Sql – the best implementation for DB Audit Trail?


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.

Best Solution

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.