Possible Duplicate:
Auditing SQL Server data changes
My requirements demand for each row inserted and updated in the database to track who made the change (creator/modifier), when the record was created and when it was modified. I have guids for row IDs in all tables, so I thought I would come up with a table rowdata
rowdata
: created (datetime)
, modified (datetime)
, createdby
(string or user id), modifiedby
and maybe summary
column (string, summary of changes)
and then put some insert/update triggers in place. Do you think is fine or is there another wa (maybe out-of-the-box one)?
My dev environment is .NET 4, so if you think of other options that might come into question, please tell.
I have similar requirements but went about it by adding these four columns to all the tables that needed the auditing tracked:
The INSERT trigger looks like:
And the UPDATE trigger looks like:
The SUSER_SNAME() function is useful for use because we are using impersonation in our app and windows authentication to connect to the DB. This may not work in your case.