This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a script to find who last performed the DDL changes in SQL Server.
As a DBA, this script is handy to monitor recent DDL changes in SQL Server.
Below is a script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
SELECT te.name AS eventtype ,t.loginname ,t.spid ,t.starttime ,t.objectname ,t.databasename ,t.hostname ,t.ntusername ,t.ntdomainname ,t.clientprocessid ,t.applicationname FROM sys.fn_trace_gettable ( CONVERT (VARCHAR(150) ,( SELECT TOP 1 value FROM sys.fn_trace_getinfo(NULL) WHERE property = 2 )),DEFAULT ) T INNER JOIN sys.trace_events as te ON t.eventclass = te.trace_event_id WHERE eventclass=164 |
In the above script, sys.fn_trace_getinfo(NULL) will fetch default trace file.