使用列名保留上一列值和修改后的值? [英] keep previous column value and modified value with column name?

查看:51
本文介绍了使用列名保留上一列值和修改后的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我有一个像tblEmp的表格,在我的表格中我有一些像Id,Name这样的栏目



让我的表中的一些数据为1,Ashok

如果任何用户将此记录更改为1,Ashok Kumar代替 Ashok



所以最后我们必须将数据显示为 -



列名 - [名称] Ashok来自Ashok Kumar改编为





那么我们如何展示ColumnName,之前的Text和ModifyText?



请建议?

Hello All,

I have a table like "tblEmp" and in my table i have some column like "Id","Name"

let inser some data in my table as 1, "Ashok"
If any user change this records as 1,"Ashok Kumar" in place of "Ashok"

So finally we have to show data as -

Column Name- [Name] "Ashok" chnaged from "Ashok Kumar" with modifiedby


So how we show ColumnName, previous Text and ModifyText?

Please suggest?

推荐答案

您应该考虑使用另一个表来显示历史/审计跟踪更改的值,如当前父表中的数据或历史上仅保留在历史表中的每列。检查最新行以获取对象的当前状态。首选,因为避免了数据库中重复数据的问题或者必须查看多个表中相同数据的问题。



类似



UserTable(user_id,user_name)user_History(history_id,change_datetime,description,username,usernamechanged)//新值可以保存在此处,也可以删除,因为它已经可以使用了。



希望这有帮助...
You should consider having another table to show the historical /audit trail changed values like "current" data in the parent table or each column that is kept historically in the historical table only. Check latest row to get the current state for the object. Preferred since avoids the problem of duplicate data in your database or having to look at multiple tables for the same data.

Something like

UserTable (user_id, user_name) user_History (history_id, change_datetime, description, username, usernamechanged)//new value can saved here or can be removed since its already in usertable.

Hope this helps...


看看这篇文章,特别是关于更新后触发器的部分。



触发器 - SQL Server [ ^ ]
Have a look at this article, especially the section on "after update" triggers.

Triggers -- SQL Server[^]






您可以使用更新触发器。

请参阅以下链接。它会对你有所帮助。



http://stackoverflow.com/questions/7796281/sql-triggers-how-do-i-get-the-updated-value [ ^ ]


这篇关于使用列名保留上一列值和修改后的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆