devxlogo

Discover Long-Running Queries

Let SQL Server tell you which queries take the longest to run. The following query returns the five longest-running queries. You can change the TOP 5 to whatever number best meets your needs.

SELECT TOP 5 t.TEXT query,    stats.max_elapsed_time AS MaxElapsedTime,FROM sys.dm_exec_query_stats statsCROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) tORDER BYs.max_elapsed_time DESC

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Engineering Leaders Spot Weak Proposals

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.