Hopefully I'm just missing the obvious with this one ....
Using the SQL Server 7.0 Books On-Line Help files I've successfully set up triggers for the INSERT and DELETE actions against a table Table1 (making an appropriate time-stamped entry in a log table Table1_2) but now need to do the same for the UPDATE action against Table1 entries. Can anyone give me a pointer how I should be doing this ?
The INSERT/DELETE action triggers are detailed here :
CREATE TRIGGER [Table1_TRG_1] ON dbo.Table1
FOR INSERT
AS
INSERT INTO [Table1_2]
([DtAction], [Action], [Field1], [Field2], [Field3], [Field4])
SELECT
GetDate(), 'NEW', ins.[Field1], ins.[Field2], ins.[Field3], ins.[Field4]
FROM inserted ins
CREATE TRIGGER [Table1_TRG_2] ON dbo.Table1
FOR DELETE
AS
INSERT INTO [Table1_2]
([DtAction], [Action], [Field1], [Field2], [Field3], [Field4])
SELECT
GetDate(), 'DLT', dlt.[Field1], dlt.[Field2], dlt.[Field3], dlt.[Field4]
FROM deleted dlt
Thanks in advance.
Steve
Using the SQL Server 7.0 Books On-Line Help files I've successfully set up triggers for the INSERT and DELETE actions against a table Table1 (making an appropriate time-stamped entry in a log table Table1_2) but now need to do the same for the UPDATE action against Table1 entries. Can anyone give me a pointer how I should be doing this ?
The INSERT/DELETE action triggers are detailed here :
CREATE TRIGGER [Table1_TRG_1] ON dbo.Table1
FOR INSERT
AS
INSERT INTO [Table1_2]
([DtAction], [Action], [Field1], [Field2], [Field3], [Field4])
SELECT
GetDate(), 'NEW', ins.[Field1], ins.[Field2], ins.[Field3], ins.[Field4]
FROM inserted ins
CREATE TRIGGER [Table1_TRG_2] ON dbo.Table1
FOR DELETE
AS
INSERT INTO [Table1_2]
([DtAction], [Action], [Field1], [Field2], [Field3], [Field4])
SELECT
GetDate(), 'DLT', dlt.[Field1], dlt.[Field2], dlt.[Field3], dlt.[Field4]
FROM deleted dlt
Thanks in advance.
Steve