How do I create a trigger to capture who is changing data in a table ?
Posted on 2007-03-27
I would like to create a trigger to track who made what changes to a table, but I'm really lost on this one.
I have created a table named "ChangeLog" with the following fields:
I have just barely started the coding:
CREATE TRIGGER [TRIGGER NAME] ON [dbo].[ShippingMaster]
FOR INSERT, UPDATE, DELETE
INSERT INTO ChangeLog
(ChangeDate, DataTable, Field, BeforeData, AfterData, ChagedBy)
VALUES(GetDate(), ===> now I'm lost...
I guess my biggest question is how do I capture values for who is changing the data, and what the before and after values are ?