How can we help you today?

How to Find the Last Execution Time of a SQL Stored Procedure

Issue
When troubleshooting application and database issues, gathering some information regarding the stored procedures
could be very helpful in leading to the resolution or to identifying the cause of problems.

Product
Struxureware Power Monitoring
Power Monitoring Expert
ION Enterprise
ION EEM

Environment
Microsoft SQL Server

Cause
Database maintenance and troubleshooting possible application and database issues.

Resolution
*Warning: Irreparable database damage can occur. This procedure should only be performed by users familiar with SQL Server Management Studio. Databases should be backed up prior to performing this procedure.*

Execute the SQL query below, replacing YourSpName with the name of the stored procedure you are interested in, to find the last time a the procedure was executed.

SELECT st.text as SQL,qs.creation_time,qs.last_execution_time,qp.dbid,qp.objectid
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle)AS st
CROSS APPLY sys.dm_exec_text_query_plan(qs.plan_handle,DEFAULT,DEFAULT)AS qp
WHERE st.text like '%YourSpName%'


Note: contents of the DMVs will clear while restarting the SQL service, so the contents wont always be accurate.

** see attachment containing the SQL script text

Schneider Electric Canada

Attachment(s)
ExecutionTime.txt [11.56 KB]
Explore more
Category:
Users group

Discuss this topic with experts

Visit our community and get advice from experts and peers on this topic and more
Explore more
Category:

Need help?

Need help?

Product Selector

Product Selector

Quickly and easily find the right products and accessories for your applications.

Get a Quote

Get a Quote

Start your sales inquiry online and en expert will connect with you.

Where to buy?

Where to buy?

Easily find the nearest Schneider Electric distributor in your location.

Help Center

Help Center

Find support resources for all your needs, in one place.

  • Help and Contact Center
  • Contact Sales
  • Find our Offices
  • Where to Buy
  • Careers
  • Company Profile
  • Investors
  • Newsroom
  • Report a Misconduct
  • Product Documentation
  • Product Selectors
  • Software and Firmware
  • Product Substitution and Replacement
  • Blog
  • Events
  • Schneider Electric Community
  • Sustainability
  • Legal Information
  • Privacy Policy
  • Cookie Notice
  • Terms of use
  • Change your cookie settings