Tim
Tim

Reputation: 337

How do I know if a database trigger is DROP_TABLE or ALTER_TABLE?

If I create a database trigger in SQL Server 2008 which triggers on both DROP_TABLE and ALTER_TABLE, how do I determine whether this is a DROP or an ALTER?

Upvotes: 3

Views: 92

Answers (1)

Martin Smith
Martin Smith

Reputation: 453298

Inside the trigger you can test

SELECT EVENTDATA().value('(/EVENT_INSTANCE/EventType)[1]','sysname')

It will be DROP_TABLE or ALTER_TABLE

Documentation for EVENTDATA

Upvotes: 5

Related Questions