How can I find the last modified date, modified user of an stored procedure in SQL Server 2008?

前端 未结 8 671
无人共我
无人共我 2021-02-01 23:50

I need to find the user name of the person who modified a particular stored procedure.

How do I find out when a stored procedure was last modified or compiled in Oracle?

相关标签:
8条回答
  • 2021-02-01 23:55

    Can you try this out?

    SELECT name, create_date, modify_date FROM sys.procedures

    0 讨论(0)
  • 2021-02-01 23:55

    If you are going to need this information in the future, it may be worth looking at implementing a DDL trigger on the CREATE_PROCEDURE and ALTER_PROCEDURE DDL events

    Example B from the EVENTDATA page shows a trigger logging all DDL events, with user name captured.

    0 讨论(0)
  • 2021-02-01 23:58

    I tried the following query and it worked for me:

    SELECT *
    FROM sys.objects
    WHERE type = 'P'
    ORDER BY modify_date DESC
    

    This query is for stored procedures.

    0 讨论(0)
  • 2021-02-02 00:00

    Here what it works for me:-

    DECLARE @filename VARCHAR(255) 
    SELECT @FileName = SUBSTRING(path, 0, LEN(path)-CHARINDEX('\', REVERSE(path))+1) + '\Log.trc'  
    FROM sys.traces   
    WHERE is_default = 1;  
    
    SELECT gt.HostName, 
           gt.ApplicationName, 
           gt.NTUserName, 
           gt.NTDomainName, 
           gt.LoginName, 
           gt.SPID, 
           gt.EventClass, 
           te.Name AS EventName,
           gt.EventSubClass,      
           gt.TEXTData, 
           gt.StartTime, 
           gt.EndTime, 
           gt.ObjectName, 
           gt.DatabaseName, 
           gt.FileName, 
           gt.IsSystem
    FROM [fn_trace_gettable](@filename, DEFAULT) gt 
    JOIN sys.trace_events te ON gt.EventClass = te.trace_event_id 
    WHERE EventClass in (164) --AND gt.EventSubClass = 2
    ORDER BY StartTime DESC;
    

    Source:- https://serverfault.com/questions/258111/finding-out-who-has-modified-a-stored-procedure-on-sql-server

    0 讨论(0)
  • 2021-02-02 00:03

    Try Schema Changes History Report.

    In SQl Server Management Sudio -> Right Click on server name or schema name -> Reports -> Standard Reports -> Schema Changes History

    This worked for me like a charm.

    Taken from here

    0 讨论(0)
  • 2021-02-02 00:12

    Procedure changes are traced in the system default trace. Simply open the .trc file from your ...\MSSQL\LOG folder and search for the ALTER PROCEDURE. The only problem is that the default trace gets rewriten in time, so you can only use it for recent changes (days-weeks).

    0 讨论(0)
提交回复
热议问题