hi all,
i want to do something like that; if someone tries to update a table, the trigger will fire and add a new record that contains the field name, old value and new value.
i have already done a small part of it.
the code is below.
as you see, the trigger fires up with any update on test2 db.
but current code only controls the "name" field of the table name_surname.
i want it to go after every field and log them.
thank you.
i want to do something like that; if someone tries to update a table, the trigger will fire and add a new record that contains the field name, old value and new value.
i have already done a small part of it.
the code is below.
Code:
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[forumchange] ON test2 FOR UPDATE AS BEGIN Declare @newNAME varchar(64) Declare @oldNAME varchar(64) declare @date datetime Select @oldNAME = ad from deleted Select @newNAME = ad from inserted select @date = getdate() if (@newNAME is not null) and (@oldNAME is not null) insert into test3 (oldNAME,newNAME,date) values (@oldname,@newname,@date) END
but current code only controls the "name" field of the table name_surname.
i want it to go after every field and log them.
thank you.
Comment