且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何捕获表中的更新值

更新时间:2023-02-05 08:54:09

这是跟踪修改日志或备份旧数据以备将来使用的好主意.
为此,您需要这样做...

1)首先,您需要添加一个表,该表将用于存储旧值,然后再进行更新.....

像这样的架构...

ID,TABLENAME,COLUMNAME,RecordID,OLDVALUE,UPDATEDVALUE

//这里记录ID表示记录的主键或ID

2)然后创建一个触发器,该触发器将在修改旧数据之前执行操作以备份您的旧数据....

3)然后您可以使用该备份数据来显示具有更新值的旧值...

有关触发器的更多信息,请参考此链接...

如何检查是否插入或插入 [ ^ ]
Thats great idea to track log of modification or back up you old data for future use....

for achieving this you need to do like this...

1) first of all you need to add one table, that table will used for storing old value before it will be updated.....

Schema Like this...

ID,TABLENAME,COLUMNAME,RecordID,OLDVALUE,UPDATEDVALUE

//here Record ID means the primary key or id of your record

2) then create a trigger that will perform operation for backup your old data before modified that....

3) then you can use that backup data for for showing old value with updated value...

For more about trigger you can please refer this link...

how to check whether it is inserte or update or delete in how to check whether it is update or delete in sql server trigger..?[^]