When was Stored Procedure Last Compiled? – Interview Question of the Week #292


 

Question: When was Stored Procedure Last Compiled?

Answer: Honestly, it is difficult to figure out when was the stored procedure last compiled. As a matter of fact, SQL Server does not keep this information out in the public, that is why I understand. However, just like everything else in the SQL Server, I believe there is a workaround for this one.

In SQL Server DMV sys.dm_exec_procedure_stats there is a column which is called cached_time. While not 100% accurate but we can assume that when the stored procedure was compiled at that time it might have got cached in the memory. Now there