Reputation: 24679
I have a database trigger that logs DDL changes. It has the folowing format
CREATE TRIGGER [Log_DDL_Changes]
ON DATABASE
FOR
CREATE_TABLE, ALTER_TABLE, DROP_TABLE,
CREATE_INDEX, ALTER_INDEX, DROP_INDEX,
CREATE_PROCEDURE, ALTER_PROCEDURE, DROP_PROCEDURE,
CREATE_VIEW, ALTER_VIEW, DROP_VIEW,
CREATE_FUNCTION, ALTER_FUNCTION, DROP_FUNCTION, RENAME
--Fires only for CREATE / ALTER / DROP Table and PROCs
AS
BEGIN
.
.
.
END
I'd like to add special handling whenever a table, view or index is created or changed.
How can I determine which event triggered the trigger for a TRIGGER that handles multiple events?
Upvotes: 2
Views: 259
Reputation: 56725
You use something like this in your trigger:
SELECT EVENTDATA().value('(/EVENT_INSTANCE/EventType)[1]','nvarchar(max)')
Upvotes: 1