-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathQuery-WhoIsActive.sql
More file actions
47 lines (46 loc) · 1.43 KB
/
Copy pathQuery-WhoIsActive.sql
File metadata and controls
47 lines (46 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
SELECT collection_time,
[dd hh:mm:ss.mss],
-- ,Left(cast(sql_text as varchar(max)),50) SQLText
sql_text,
sql_command,
-- , Left(cast(sql_command as varchar(max)),50)SQLCommand
[session_id],
[login_name],
[wait_info],
[tran_log_writes],
[CPU],
[tempdb_allocations],
[tempdb_current],
[blocking_session_id],
[blocked_session_count],
[reads],
[writes],
[physical_reads],
[query_plan],
[used_memory],
[status],
[tran_start_time],
[open_tran_count],
[percent_complete],
[host_name],
[database_name],
[program_name],
[start_time],
[login_time]
FROM dbo.tblWhoIsActive WITH (nolock)
WHERE 1 = 1
--AND database_name LIKE 'DBName'
--AND CAST(sql_text AS VARCHAR(MAX)) LIKE '%QueryText%'
--AND CAST(sql_command AS VARCHAR(MAX)) LIKE '%QueryText%'
--AND (blocking_session_id IS NOT NULL OR blocked_session_count > 0) --Just find blocking details
--AND host_name LIKE 'ServerName'
--AND percent_complete > 20
--AND login_name LIKE 'LoginName'
--AND program_name LIKE '%ProgramName'
--and query_plan is not null
--and session_id = 55
AND collection_time > DATEADD(MINUTE, -15, GETDATE())
--AND collection_time > '2018-03-16 11:14:01.090'
--AND collection_time < '2018-03-16 11:14:01.090'
ORDER BY 1 DESC;
--ORDER BY tempdb_current DESC