CPU usage by query | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

CPU usage by query

Hello,
I wanted to know how can I get the server CPU percent usage by
a query. I want to write a stored procedure that returns the current
cpu percent.
(same percent that is displayed by the windows Task Manager on the server)
I couldn’t understand how can retrieve it from sysprocesses table.
Thanks,
XSO
I guess you have to use performance monitors-> export to excel-> load it into tables->query from SP. i know this is a very lengthy process. but i couldnt think of a better one… Thanks,
Ram "It is easy to write code for a spec and walk in water, provided, both are freezed…"
you might take a look at the reports in SSMS. I think they have this information. They are in the summary page, under the "Report" drop down. Which reports are available depend on the type of node that’s selected in OE. Select a server node in OE, and you’ll see a bunch of reports that start with "Performance". Those may help you. To see what queries they are running (they all go agaist the DMVs) you can download the reports here (or just run profiler):
http://blogs.msdn.com/sqlrem/archive/2006/08/30/SSMS_Reports_3.aspx (look for "SSMS Standard Reports.zip" on that page) hope this helps!
SqlSpec – a fast, cheap, and comprehensive data dictionary generator
for SQL Server 2000 and 2005 and Analysis Server 2005 – www.elsasoft.org

]]>