첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
SELECT TOP 10
    REPLACE(CONVERT(VARCHAR(20), CONVERT(MONEY, A.total_worker_time / A.execution_count/1000), 1), '.00', '') AS [Avg CPU Time(ms)]
   ,A.execution_count
   ,SUBSTRING
    (
        B.text,
        A.statement_start_offset / 2 + 1,
        (
            CASE
                WHEN A.statement_end_offset = -1 THEN LEN(CONVERT(NVARCHAR(MAX), B.text)) * 2
                ELSE                                  A.statement_end_offset
            END - A.statement_start_offset
        ) / 2
    ) AS query_text
   ,B.dbid
   ,D.name
   ,B.objectid
   ,B.number
   ,B.encrypted
   ,B.text
   ,E.session_id
   ,E.command
   ,E.status
   ,E.last_wait_type
   ,E.wait_resource
   ,C.query_plan
   ,F.text
FROM            sys.dm_exec_query_stats                AS A
CROSS APPLY     sys.dm_exec_sql_text(A.sql_handle)     AS B
CROSS APPLY     sys.dm_exec_query_plan(A.plan_handle)  AS C
LEFT OUTER JOIN sys.databases                          AS D ON D.database_id = B.dbid
LEFT OUTER JOIN sys.dm_exec_requests                   AS E ON E.sql_handle  = A.sql_handle
OUTER APPLY     sys.fn_get_sql(E.sql_handle)           AS F
ORDER BY A.total_worker_time / A.execution_count DESC
GO
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요