We have several applications that are updating a certain ms sql 2005 table (asp.net web app, c# windows service, email parser to database automation tool (uses sql + VB)) and would like to store audit information on the table. E.g. ModifiedBy, ModifiedDate where ModifiedBy = Name of Application updating the record.
We would also like to archive the information on the table; when we update a particular record, store the current record in an myTable_Archive table and stamp it with a date and update the current record in myTable accordingly.
What’s the best maintainable and testable approach to solving this while keeping the impact minimal to the existing applications? Or can someone suggest a better route? Calling a store procedure, c# shared library (using nhibernate/ado.net,etc.), or an ms sql 2005 built-in feature if any for example.
The most maintainable (and fairly standard) way of doing this kind of auditing is to use triggers on the tables in question.
Since they exist entirely in the database, your applications will not change at all.
Of course, triggers will impact performance (since one now changes more than one table in a call).