How to get original values ​​in SQL update trigger

I am not very familiar with triggers, so thank you for your patience.

I have a database table with four columns for user text input and a total of four date columns showing when the user's last text input was changed. What I want the trigger to do is to compare the original and new values ​​of the user text input columns, and if they are different, update the date column with getdate (). I do not know how to do that. The code I wrote cannot get the value of the field’s preliminary update, so it cannot be compared with the value after the update. Does anyone know how to do this?

(I usually did this in a stored procedure, but this database table can also be edited directly in the Access database, and we cannot convert these changes to using a stored procedure. This only gives us the ability to use a trigger.)

+3
source share
1 answer

There are two special tables in the sql server available in a trigger called insert and deleted. The same structure as the table on which the trigger is implemented. new versions are inserted, old ones are deleted.

+3
source

All Articles