Sr. ID FName LName Mark
1 P1 amar ranjan 100
2 P2 sameer kumar 200
3 P1 amar ranjan 200
Here I updated the first row for Mark column.
On each update to a single row I am creating the new row (see row 3) with updated value.
Is it possible to get the column name which have been updated in the table?
I used Mahmoud Gamal’s answer and SQL Fiddle demo as a starting point.
What you need is possible, but if you have access to the update processes I would recommand to manage the updates in any a stored procedure which saved the changes directly in a table.
If you need a trigger, something like this can work, but as you see, it has it’s own drawbacks: two temporary table because of the scope and a cursor.
It basicly generates a check for each column each time and inserts the new and old values for a column into the history table.
(a change on the ID column to Primary Key and Identity is recommanded too)
I also made an SQL FIDDLE demo