J
Jeff via AccessMonster.com
I have an audit table that gets inserted with records on the update trigger
of the table it audits. My problem is that I only to update the fields that
have been changed in the audit table (i.e. any fields not changed should be
null). Here is my trigger:
CREATE TRIGGER UpdatePeople ON dbo.People
FOR UPDATE
AS
INSERT [People_Audit]
(SYSID, Name, Address, ChangeType, ChangeDate, ChangedBy)
SELECT SYSID, Name, Address, 'Update', GetDate(), SUSER_SNAME()
FROM inserted
My guess is that in the SELECT statement I should have something like IF
Update(...) for each field but I'm not too sure on this and can't get it to
work. Thanks,
of the table it audits. My problem is that I only to update the fields that
have been changed in the audit table (i.e. any fields not changed should be
null). Here is my trigger:
CREATE TRIGGER UpdatePeople ON dbo.People
FOR UPDATE
AS
INSERT [People_Audit]
(SYSID, Name, Address, ChangeType, ChangeDate, ChangedBy)
SELECT SYSID, Name, Address, 'Update', GetDate(), SUSER_SNAME()
FROM inserted
My guess is that in the SELECT statement I should have something like IF
Update(...) for each field but I'm not too sure on this and can't get it to
work. Thanks,