Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Update Trigger to Store Only Updated Column and Former Value

By Larry Schmidt,

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.

Total article views: 1021 | Views in the last 30 days: 3
 
Related Articles
FORUM

Table with status column that looks up history table based on date

SQL 2000, computed columns, status history table

FORUM

Backup history

Backup history

FORUM

History actions

History actions

FORUM

Column value changed?

When did the Column Schema changed Date Time?

FORUM

the use history from table

the use history from table

Tags
history    
trigger    
update    
 
Contribute