last exected date for stored proc

  • Hi All,

    Is it possible to find out the last executed date for any stored proc in the database using system tables or writing any other query.

    Thanks.

  • No.

    If the procedure has been executed recently, and the plan is still in cache, then you can query sys.dm_exec_procedure_stats, but a procedure will only have an entry in there if its plan is still in the plan cache, and that is dependent on memory pressure and activity on the server and is cleared on a restart.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I often need to know the last time a proc ran and if it finished. So I created a simple table that logs start datetime, end datetime and any error code captured. I'm not sure I'd suggest this for a proc that was going to run a huge amount, I often only need to track ones that might run only every 5 mins at most.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply