Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 how do i get 5 or 10 slowest sql statements

Author  Topic 

ankarao11
Starting Member

2 Posts

Posted - 2009-04-21 : 09:40:59
Dear All,

how do i get 5 or 10 slowest sql statements in MS Sql server 2005

Txs

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-21 : 09:47:23
You can either use some of the built-in new DM views, or you can profile the server with SQL profiler.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

ankarao11
Starting Member

2 Posts

Posted - 2009-04-21 : 11:07:33
Dear Peso,

i am new to sql server. and txs for ur response.

could you please tell me in more detail.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2009-04-21 : 12:37:51
select top 5
p.text
from sys.dm_exec_query_stats s
CROSS APPLY sys.dm_exec_sql_text(s.plan_handle) p
order by
s.max_elapsed_time Desc

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -