tomjscribe
Programmer
Writing a generic trigger for all operations (Update, Insert, Delete).
How can I tell what type of operation against the table has occurred.
I want one, generic I/U/D trigger that needs slightly different behavior for each operation.
Basically, I am writing an 'audit trail' trigger and need to record the operation type in an audit table.
For example:
IF @opertype = "Delete"
BEGIN
INSERT AuditTable (operation_type) VALUES ("D"
END
ELSE
IF @opertype = "Update"
BEGIN
INSERT AuditTable (operation_type) VALUES ("U"
END
ELSE
IF @opertype = "Insert"
BEGIN
INSERT AuditTable (operation_type) VALUES ("I"
END
Thanks!
How can I tell what type of operation against the table has occurred.
I want one, generic I/U/D trigger that needs slightly different behavior for each operation.
Basically, I am writing an 'audit trail' trigger and need to record the operation type in an audit table.
For example:
IF @opertype = "Delete"
BEGIN
INSERT AuditTable (operation_type) VALUES ("D"
END
ELSE
IF @opertype = "Update"
BEGIN
INSERT AuditTable (operation_type) VALUES ("U"
END
ELSE
IF @opertype = "Insert"
BEGIN
INSERT AuditTable (operation_type) VALUES ("I"
END
Thanks!