T_SQL::SP_WHO2 + DBCC
-
--===================================
-
-- SP_WHO2와명령어동시확인하기
-
--===================================
-
SELECT
-
ISNULL(D.text, '') AS SQLStatement,
-
object_name(D.objectid) AS 'sp_ame',
-
A.Session_ID SPID,
-
ISNULL(B.status,A.status) AS [Status],
-
A.login_name AS [Login],
-
ISNULL(A.host_name, ' .') AS HostName,
-
ISNULL(CAST(C.BlkBy AS varchar(10)), ' .') AS BlkBy,
-
DB_NAME(B.Database_ID) AS DBName,
-
B.command,
-
ISNULL(B.cpu_time, A.cpu_time) AS CPUTime,
-
ISNULL((B.reads + B.writes),(A.reads + A.writes)) AS DiskIO,
-
A.last_request_start_time AS LastBatch,
-
ISNULL(A.program_name, '') AS ProgramName,
-
ISNULL(A.client_interface_name, '') AS ClientInterfaceName
-
FROM sys.dm_exec_sessions A
-
LEFT OUTER JOIN sys.dm_exec_requests B ON A.session_id = B.session_id
-
LEFT OUTER JOIN (
-
SELECT A.request_session_id SPID, B.blocking_session_id BlkBy
-
FROM sys.dm_tran_locks A
-
INNER JOIN sys.dm_os_waiting_tasks B ON A.lock_owner_address = B.resource_address
-
) C ON A.Session_ID = C.SPID
-
OUTER APPLY sys.dm_exec_sql_text(B.sql_handle) D
-
go
이 글은 스프링노트에서 작성되었습니다.
'Monitoring' 카테고리의 다른 글
T-SQL:: Default Trace로 DB 증가량 확인 (1) | 2011.04.15 |
---|---|
Admin::Tempdb 의 작업, 모니터링 (0) | 2011.01.30 |
CPU에 할당된 Task 보기 (1) | 2010.03.14 |
DBCC FLUSHPROCINDB (0) | 2010.02.04 |