voxinforma
MIS
I would like to create an audit table that would record old and new values whenever data is modified in any table.
My database might look like this:
table1 (table1ID, field1, field2)
table2 (table2ID, field1, field2)
and my audit table like this:
AuditTable (AuditTableID, TableName, FieldName, ID, OldValue, NewValue)
I am trying to use triggers on table1 and table2 via the Deleted and Inserted tables to write OldValue and NewValue, but cannot figure out how to get the approprite TableName. I only want to add the changed values to AutitTable; unchanged values should not be added.
Any help would be appreciated.
Thanks.
My database might look like this:
table1 (table1ID, field1, field2)
table2 (table2ID, field1, field2)
and my audit table like this:
AuditTable (AuditTableID, TableName, FieldName, ID, OldValue, NewValue)
I am trying to use triggers on table1 and table2 via the Deleted and Inserted tables to write OldValue and NewValue, but cannot figure out how to get the approprite TableName. I only want to add the changed values to AutitTable; unchanged values should not be added.
Any help would be appreciated.
Thanks.