I wrote a trigger which fires when update on Employee table.
When trigger fires it insert new record to Transact table.
ALTER TRIGGER [PROJECTS].[after_updateEmployee] ON [PROJECTS].[Employee]
AFTER UPDATE
AS DECLARE @tablen varchar(30) , @modyfire varchar(15),@modyfied_date datetime,@columname varchar(20),@action varchar(6)
SET @tablen ='Employee'
set @modyfire =(SELECT SYSTEM_USER)
set @modyfied_date =(select CURRENT_TIMESTAMP)
SET @columname = (SELECT TOP 1 E_id FROM PROJECTS.Employee ORDER BY RV DESC)
set @action ='UPDATE'
BEGIN
INSERT INTO PROJECTS.Transact values(@tablen,@modyfire,@modyfied_date,@columname,@action)
END
I have more tables in my database.So is there any way to use this trigger for all tables in my database.
Thank You.
selectstatements over theinformation_schemaand then applying the triggers automatically (by running the script).insertedand/ordeletedpseudo-tables. This trigger appears to have both issues.