Search code examples
sql-serversyslog

SQL Server 2008 log of dropped stored procs


I am using SQL Server 2008 and noticed that an important stored procedure was missing.

How do I find out when and by whom a stored procedure was dropped.


Solution

  • First you get location of admintrace:

    select * from fn_trace_getinfo(NULL)
    where property=2
    and traceid in (1,2,3,4,5) --sometime several logs available
    

    and then you check all details:

    select DatabaseName,ObjectName,LoginName,StartTime,* 
    from fn_trace_gettable('c:\path_to_log\MSSQL\Log\log_2.trc', -1)
    where EventClass = 47  --Object:Deleted