SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Queries running in particular data base
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cherukuri222
Starting Member

India
4 Posts

Posted - 03/28/2013 :  15:11:40  Show Profile  Reply with Quote
1) How many queries are hitting database?
2) What are the queries?
3) Which queries is taking long time to execute.?

In sql server 2005 and 2008

siva

TG
Flowing Fount of Yak Knowledge

USA
6062 Posts

Posted - 03/28/2013 :  15:42:55  Show Profile  Reply with Quote
sql profiler

Be One with the Optimizer
TG
Go to Top of Page

cherukuri222
Starting Member

India
4 Posts

Posted - 03/29/2013 :  02:27:01  Show Profile  Reply with Quote
hi TG
i think sql profiler is not preferable in sql server.
please give another solution , in T-Sql

siva
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2217 Posts

Posted - 03/29/2013 :  03:36:34  Show Profile  Reply with Quote
--To Display the Top 25 Most expensive read I/O queries
SELECT TOP 25 cp.usecounts AS [execution_count]
     ,qs.total_worker_time AS CPU      
     ,qs.total_elapsed_time AS ELAPSED_TIME      
     ,qs.total_logical_reads AS LOGICAL_READS      
     ,qs.total_logical_writes AS LOGICAL_WRITES      
     ,qs.total_physical_reads AS PHYSICAL_READS       
     ,SUBSTRING(text,                    
				CASE WHEN statement_start_offset = 0                           
				OR statement_start_offset IS NULL                             
				THEN 1                             
				ELSE statement_start_offset/2 + 1 END, 
				CASE WHEN statement_end_offset = 0                           
				OR statement_end_offset = -1                            
				OR statement_end_offset IS NULL                             
				THEN LEN(text)                             
				ELSE statement_end_offset/2 END -                      
				CASE WHEN statement_start_offset = 0                             
				OR statement_start_offset IS NULL                              
				THEN 1                               
				ELSE statement_start_offset/2  END + 1                   
				)  AS [Statement]        
FROM sys.dm_exec_query_stats qs     join sys.dm_exec_cached_plans cp on qs.plan_handle = cp.plan_handle    CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) st ORDER BY qs.total_logical_reads DESC;
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 03/29/2013 :  13:49:28  Show Profile  Reply with Quote
quote:
Originally posted by cherukuri222

hi TG
i think sql profiler is not preferable in sql server.
please give another solution , in T-Sql

siva


why profiler is not preferable?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000