The SCD_Project table stores data about IT projects, and the SCD_History table is an audit reference, in which is stored a row for any change made to a specific column in several other tables. For that reason, the History table has columns for the source table, column, rowlink (primary key of that table), and value prior to update. The LastModifiedDate and LastModifier (11-character employee ID) are columns common to all tables which have triggers that write to the History table. In addition, using a cursor was avoided by adding a RowID (identity) and stepping through the changed columns. The changed columns and their names are obtained through the use of the sys.fn_IsBitSetInBitmask function.
Trigger Happy
This article looks at using triggers to audit and to prevent the performing of unintended actions.
2018-10-12 (first published: 2016-03-28)
4,299 reads