USE master
SELECT TOP 10
REPLACE(CONVERT(VARCHAR(20), CONVERT(MONEY,qs.total_worker_time / qs.execution_count/1000),1),'.00','') as [Avg CPU Time(ms)]
,qs.execution_count
,substring (qt.text,
qs.statement_start_offset/2+1,
(case when qs.statement_end_offset = -1 then len (convert (nvarchar(max), qt.text)) * 2
else qs.statement_end_offset end - qs.statement_start_offset)/2) as query_text
,qt.dbid
,sd.name
,qt.objectid
,qt.number
,qt.encrypted
,qt.text
,sr.session_id
,sr.command
,sr.status
,sr.last_wait_type
,sr.wait_resource
,sq.query_plan
,fs.text
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as qt
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) as sq
LEFT OUTER JOIN sys.databases as sd on qt.dbid = sd.database_id
LEFT OUTER JOIN sys.dm_exec_requests as sr on qs.sql_handle = sr.sql_handle
OUTER APPLY sys.fn_get_sql(sr.sql_handle) AS fs
ORDER BY qs.total_worker_time / qs.execution_count DESC
GO
'DB' 카테고리의 다른 글
(MSSQL) sp_ 리스트 (0) | 2017.04.13 |
---|---|
(MSSQL) select시 최대허용크기(8094)초과 및 테이블생성시 최대바이트수(8060) 초과오류시 해결방법 (0) | 2017.04.13 |
(MSSQL) 프로시저 이력보기 (delete , create, modify) (0) | 2017.04.13 |
(MSSQL) 테이블 컬럼 명칭 변경 (0) | 2017.04.13 |
(MSSQL) xml 저장프로시저 (0) | 2017.04.13 |