Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to find location in database of CPU intensive query?

I have a server called "Reporting" and looking at SQL Server performance reports, specifically "Top Queries by Total CPU Time". I have found the top CPU Time consuming queries.

The number 1 query shows me the "Query Text", "Database Name", "Object ID" and "Total CPU Time".

I would like to go and optimize the code of that query but I only know the database where the query is from but not the exact location folder or name of the query.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there any way of how one can go about finding the exact name and location of the query?

 For Example:
Top CPU Expensive Query is in Database "Training", ObjectID "1727285326", Query text +- 500 lines of SQL code. 
Where do I go look in the "Training" Database for the query since I only see the Query Text and Object ID?

Any help or right direction would be much appreciated.

>Solution :

As you have the object id you can just use the following to find the object

USE Training;

SELECT OBJECT_SCHEMA_NAME(1727285326) AS schema_name,
       OBJECT_NAME(1727285326)        AS object_name; 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading