You need to create a CLR DDL trigger.
The solution creates a DDL trigger that executes when CREATE TABLE and DROP TABLE DDL statements are executed and logs the events to a table named Log.
The solution uses a single table named Log. Execute the following T-SQL statement to create the table:
USE AdoDotNet35Cookbook GO CREATE TABLE Log ( LogID int IDENTITY(1,1) NOT NULL, LogEntry varchar(max) NOT NULL, CONSTRAINT PK_Log PRIMARY KEY CLUSTERED ( LogID ASC ) )
Follow these steps:
...