I am trying to create a DDL trigger for a specific table, and this is the best I could come up with:
CREATE TRIGGER MyTrigger ON DATABASE FOR DDL_TABLE_EVENTS AS DECLARE @EventData xml SET @EventData=EVENTDATA() IF @EventData.value('(/EVENT_INSTANCE/ObjectType)[1]', 'varchar(50)')='TABLE' AND @EventData.value('(/EVENT_INSTANCE/ObjectName)[1]', 'varchar(50)') ='MyTable' BEGIN
Is this really the only way to do this? I looked everywhere but could not find the syntax for creating a trigger on a separate table. I think it's really stupid to use xml EVENTDATA ().
source share