Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Comments
Starlene 24-Dec-13 0:57am    
create a trigger to put the modified column to another table and join the both table with ur primary key

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...
 
Share this answer
 
Have a look at this article, especially the section on "after update" triggers.

Triggers -- SQL Server[^]
 
Share this answer
 
Hi,

you can use the update trigger.
Please see the below link. It will help you.

http://stackoverflow.com/questions/7796281/sql-triggers-how-do-i-get-the-updated-value[^]
 
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