Sql Server : Ddl Trigger, Controlling Table Creation
I'm using SQL Server 2008. I'm creating a DDL trigger like this: CREATE TRIGGER tName ON database FOR CREATE_TABLE as print 'A table has been created' Can I get that table tha
Solution 1:
Try this:
CREATETRIGGER TRG_TABLES
ON DATABASE
AFTER
CREATE_TABLE
ASBEGINSET NOCOUNT ONDECLARE@TABLE_NAME SYSNAME
SELECT@TABLE_NAME = EVENTDATA().value('(/EVENT_INSTANCE/ObjectName)[1]','SYSNAME')
...
END
GO
Solution 2:
I believe you would need to extract it from the CommandText in the EventData().
http://msdn.microsoft.com/en-us/library/ms187909.aspx
Post a Comment for "Sql Server : Ddl Trigger, Controlling Table Creation"