I am using trigger to trace DDL changes but when I change column name from the SQL Server Management Studio the trigger is not working?
create TRIGGER trgLogDDLEvent ON DATABASE
FOR DDL_DATABASE_LEVEL_EVENTS
FOR
AS
DECLARE @data XML
SET @data = EVENTDATA()
IF @data.value('(/EVENT_INSTANCE/EventType)[1]', 'nvarchar(100)')
<> 'CREATE_STATISTICS'
INSERT INTO db_trc_DDLChangeLog
(
EventType,
ObjectName,
ObjectType,
tsql,
RecDate,
HostName
)
VALUES (
@data.value('(/EVENT_INSTANCE/EventType)[1]',
'nvarchar(100)'),
@data.value('(/EVENT_INSTANCE/ObjectName)[1]',
'nvarchar(100)'),
@data.value('(/EVENT_INSTANCE/ObjectType)[1]',
'nvarchar(100)'),
@data.value('(/EVENT_INSTANCE/TSQLCommand)[1]',
'nvarchar(max)'),
getdate(),
HOST_NAME()
) ;
GO
--select * from db_trc_DDLChangeLog
--create table db_trc_DDLChangeLog
--(
--EventType varchar(max),
--ObjectName varchar(max),
--ObjectType varchar(max),
--tsql varchar(max),
--RecDate datetime,
--HostName varchar(max)
--)