I want to have a table that holds information about a task. PriorityId, StateId, AssignedToUserId etc. These columns can be updated. I’d like to be able to list the history of a task, showing the changes, and the user who made the changes. The table will have an UpdateUserId table with the user who did the update.
Should I make an identical ‘myTable_History’ table, and just use a trigger to send the entire updated (or inserted) row to the history table? Or is there a better way to do this?
Not sure if it makes a difference, but I am using soft deletes… and an identity column as the primary ket of the main table.
Now sure of a good way to show changes, but that’s another question.
Using Row-Level and Column-Level Tracking
Change Tracking enables an application to keep track of all changes made by the user and this is an inbuilt method
http://msdn.microsoft.com/en-us/library/ms172023(v=sql.90).aspx
http://msdn.microsoft.com/en-us/library/bb964713.aspx
sample
http://blogs.msdn.com/b/davidhardin/archive/2011/02/06/sql-server-2008-column-change-tracking.aspx