Triggering last change time in MSSQL
by Taavi Rammar

CREATE TRIGGER lastUserChange on users_table
FOR INSERT, UPDATE
AS
DECLARE @user_id int
SELECT @user_id = (SELECT id FROM inserted)
UPDATE users_table SET last_change = getdate() WHERE id = @user_id

Now whoever is updating any field on specific row in users_table, last_change gets updated.

P.S. This works only when you change one row at the time. To change that, you need one subquery and bit of imagination;)

Copyright by techTips