Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sql

sql-server

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?

gives me idea about the time. But how do I know the user who modified it?

like image 611
kbvishnu Avatar asked Dec 09 '10 04:12

kbvishnu


People also ask

How can I see who modified a stored procedure in SQL?

Accessing the log file in SQL Server Profiler Open the desired log file with SQL Server Profiler. You can see the stored procedure name in the ObjectName column and the name of the user who modified the stored procedure name in the LoginName column.

How do I find the last modified date in SQL?

If you need to find out which tables have been recently modified. You can check this by querying the sys. tables in TSQL based on the modify_date column. Here is the TSQL query to select the last modified table based on the recent date in SQL Server.

How do I view a stored procedure history in SQL Server?

In SQL Server 2014, you can query sys. dm_sql_referencing_entities and sys. dm_sql_referenced_entities to look for orphaned objects. As @theGameIsWar writes, you can also find the execution data for stored procedures.

How do you find out who modified an object in SQL Server?

The name of the report is Schema Changes History. To run the Schema Changes History report open SQL Server Management Studio, make a right click on an object (the instance name or a database name, for example), then select "Reports", click on "Standard Reports", and then click on "Schema Changes History" report.


1 Answers

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

like image 112
Habesha Avatar answered Oct 19 '22 10:10

Habesha