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
'IT > Database' 카테고리의 다른 글
MSSQL 유지관리계획 백업 세팅방법 (0) | 2019.02.27 |
---|---|
TABLE SIZE 계산 공식 (0) | 2018.07.23 |
[MSSQL] SQL 버전 확인 쿼리 (0) | 2018.07.11 |
[MSSQL]권한 및 테이블 복사, 업데이트(Update) Query (0) | 2018.07.09 |
[MSSQL] sqlcmd 활용하기. (0) | 2018.07.06 |
관계형 데이터 모델 (0) | 2018.05.18 |
[Oracle] MSSQL을 Oracle로 컨버전 작업 시 참조 (0) | 2018.04.30 |
[MSSQL] MS-SQL 달력만들기 SQL 문 (0) | 2018.04.27 |