AccessSQLUser
Programmer
Right now I have a trigger that runs each time a record in Table1 is updated. This trigger basically inserts a row into a log table that I have in a separate database. What I would like to do is only insert into that table the values of the fields that were changed. Any ideas?
My current trigger looks like this:
CREATE TRIGGER [trgForUpdate] ON [dbo].[Table1]
FOR UPDATE
AS
Set NoCount On
DECLARE @MyID int
SELECT @myID = ID FROM inserted
Update Table
Set [LastUpdated] = GetDate(), [LastUpdatedBy] = SUSER_SNAME() WHERE ID = @MyID
INSERT INTO DB2.dbo.Table1_Log SELECT Table1.* FROM Table1 WHERE [ID] = @MyID
My current trigger looks like this:
CREATE TRIGGER [trgForUpdate] ON [dbo].[Table1]
FOR UPDATE
AS
Set NoCount On
DECLARE @MyID int
SELECT @myID = ID FROM inserted
Update Table
Set [LastUpdated] = GetDate(), [LastUpdatedBy] = SUSER_SNAME() WHERE ID = @MyID
INSERT INTO DB2.dbo.Table1_Log SELECT Table1.* FROM Table1 WHERE [ID] = @MyID