sql server trigger for each row updated

Solutions on MaxInterview for sql server trigger for each row updated by the best coders in the world

showing results for - "sql server trigger for each row updated"
Ella
26 Jul 2020
1-- SQL Server (update my_table after update on my_table)
2CREATE TRIGGER trTest ON my_table AFTER UPDATE AS
3IF UPDATE (col_name)	-- Optional, for particular column
4BEGIN
5    UPDATE my_table SET my_col_date = getdate() FROM my_table 
6END
7-- Oracle (insert into log table after update on my_table)
8CREATE OR REPLACE TRIGGER trTest AFTER UPDATE ON my_table
9FOR EACH ROW
10BEGIN
11    INSERT INTO my_log_table (LOG_DATE, ACTION) VALUES (SYSDATE, 'Changed');
12END;