Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to get old changes of a table row?
Please see below to get close:

when I update a row:
SQL
update tTable set Note='test note 1' where id = 100 -- on 2014-05-13
update tTable set Note='test note 5' where id = 100 -- on 2014-05-16
update tTable set Note='test note 9' where id = 100 -- on 2014-05-20


then I need to know old data of [note] column of a row (id=100) on 2014-05-14!!!
In my example it should be 'test note 1'.
But, when I use CHANGETABLE(), it only shows last value.

Please help me for this issue.
Posted

1 solution

Your update command wrote the new value every time on the same row, updating the column (and if there are more than one rows with the same id it updates all of them), and SQL has no mechanism to store history - that's something you have to develop...
http://msdn.microsoft.com/en-us/library/bb933994.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900