| Author |
Topic  |
|
|
sunsanvin
Flowing Fount of Yak Knowledge
India
1256 Posts |
Posted - 11/22/2012 : 08:29:02
|
Hi All, I just want to know the currently running queries on an instance. clietn dont want to use profiler. please suggest the query.
Arnav Even you learn 1%, Learn it with 100% confidence. |
|
|
sunitabeck
Flowing Fount of Yak Knowledge
5152 Posts |
|
|
sodeep
Flowing Fount of Yak Knowledge
USA
7173 Posts |
Posted - 11/22/2012 : 12:09:36
|
| You mean queries for high CPU consumption or High I/O. You can use performance dashboard or DMV to find. |
 |
|
|
jackv
Flowing Fount of Yak Knowledge
United Kingdom
1791 Posts |
|
|
srimami
Posting Yak Master
152 Posts |
Posted - 11/22/2012 : 23:50:45
|
Use the following query adding few more parameters
SELECT d1.session_id, d3.[text], d1.login_time, d1.login_name, d2.wait_time, d2.blocking_session_id, d2.cpu_time, d1.memory_usage, d2.total_elapsed_time, d2.reads,d2.writes, d2.logical_reads, d2.sql_handle FROM sys.dm_exec_sessions d1 JOIN sys.dm_exec_requests d2 ON d1.session_id=d2.session_id CROSS APPLY sys.dm_exec_sql_text(d2.sql_handle) d3 |
 |
|
|
ahmeds08
Constraint Violating Yak Guru
India
444 Posts |
Posted - 11/28/2012 : 08:24:53
|
check this
USE MASTER SELECT TOP 50 t.[text] AS [Batch], SUBSTRING(t.[text], (qs.[statement_start_offset]/2) + 1, ((CASE qs.[statement_end_offset] WHEN -1 THEN DATALENGTH(t.[text]) ELSE qs.[statement_end_offset] END - qs.[statement_start_offset])/2) + 1) AS [Statement] , qs.[execution_count] AS [Count] , qs.[total_worker_time] AS [Tot_CPU], (qs.[total_worker_time] / qs.[execution_count]) AS [Avg_CPU] , qs.[total_physical_reads] AS [Tot_Phys_Reads], (qs.[total_physical_reads] / qs.[execution_count]) AS [Avg_Phys_Reads] , qs.[total_logical_writes] AS [Tot_Logic_Writes], (qs.[total_logical_writes] / qs.[execution_count]) AS [Avg_Logic_Writes] , qs.[total_logical_reads] AS [Tot_Logic_Reads], (qs.[total_logical_reads] / qs.[execution_count]) AS [Avg_Logic_Reads] , qs.[total_clr_time] AS [Tot_CLR_Time], (qs.[total_clr_time] / qs.[execution_count]) AS [Avg_CLR_Time] , qs.[total_elapsed_time] AS [Tot_Elapsed_Time], (qs.[total_elapsed_time] / qs.[execution_count]) AS [Avg_Elapsed_Time] , qs.[last_execution_time] AS [Last_Exec], qs.[creation_time] AS [Creation Time] FROM sys.dm_exec_query_stats AS qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS t -- ORDER BY [Tot_CPU] DESC -- ORDER BY [Avg_CPU] DESC -- ORDER BY [Tot_Phys_Reads] DESC -- ORDER BY [Tot_Logic_Writes] DESC ORDER BY [Tot_Logic_Reads] DESC -- ORDER BY [Avg_Logic_Reads] DESC -- ORDER BY [Tot_CLR_Time] DESC -- ORDER BY [Tot_Elapsed_Time] DESC -- ORDER BY [Count] DESC |
 |
|
| |
Topic  |
|
|
|