Blog Pages

Find out who modified an object in SQL Server


SELECT --T.*, 'I', I.*, 'E', E.*
E.trace_event_id, E.category_id, E.name,
T.[path], T.start_time, T.last_event_time, T.event_count,
I.NTUserName, I.NTDomainName, I.HostName, 
I.ClientProcessID, I.ApplicationName,
I.LoginName, I.SPID, I.ObjectID, I.ServerName,
I.ObjectName, I.DatabaseName, I.SessionLoginName,
I.TextData, I.BinaryData
FROM sys.traces T 
CROSS Apply ::fn_trace_gettable(T.path, T.max_files) I 
JOIN sys.trace_events E On I.eventclass = E.trace_event_id 
WHERE T.id = 1 
AND E.name = 'Object:Altered' -- or 'Object:Deleted'  or ...
--AND ObjectName like '%AnObjectName%' -- <- filter for a specific object
ORDER BY T.start_time desc

No comments:

Post a Comment