When you have an update trigger you have access to two logical table
(existing for the length of the trigger) deleted and inserted an update is
in-effect a delete followed by an insert so you can get your oldvalue and
newvalue from these linking the two or your key fields.
The insert and delete triggers only have the inserted or deleted tables
You can also see which of the fields have been modified by using the
updated(fieldname) function. here is an example
create table X (
create trigger X1 on X for update as
select i.field1,i.field2 'After',d.field2 'Before' from inserted i,deleted d
where d.field1 = i.field1
insert into X values ('1','2')
update X set field2 = '3'
I hope this was of use.
Stephen Robinson SQL MVP
> How can I create an update trigger that add
> records in a logtable, the following fields are
> Date, USER, Table, Field, Oldvalue, Newvalue
> The fields Date, User and Table are easy to use
> but i don't see how to retreive the Field, the
> oldvalue and the newvalue.
> Sent via Deja.com http://www.deja.com/
> Before you buy.