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 2000 Forums
 SQL Server Administration (2000)
 identify long running queries and send alert throu

Author  Topic 

santu4bth
Starting Member

5 Posts

Posted - 2011-04-16 : 12:49:21
Friends,

I have to find out the long running queries in my servers and I need to send alerts through Email whnever there are slow queries running.

Can anyone tell me step by step information how to perform ths task?



Thanks,

santosh v

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-16 : 15:22:30
You have to first have a baseline in order to really setup an alert for this. You can't define "long running" unless you know how long it is supposed to run under normal conditions.

But, you can use a server-side trace for this. It'll be a bit of work though on your end.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

santu4bth
Starting Member

5 Posts

Posted - 2011-04-16 : 19:30:05
I want to find the queries running more than 1000ms.
Can you provide a script to identify long running queries instead of using a profiler?I heard xp_sendmail can be used in script to send emails?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-16 : 20:25:06
There isn't a ready-made script that can do this for you. You have a lot of coding to do. You'll need to first learn server-side traces. Then if you want to use xp_sendmail, you'll need to get SQL Mail setup.

This is a huge endeavor you are undertaking.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2011-04-18 : 15:53:14
Like Tara said its not exactly an easy task...

Have server side traces set up.. have another job pick up those trace files from a shared path and load the data into another SQL instance, create a job on that instance running every few minutes or so and reading the data loaded from the trace files and send you/whoever an email if it finds queries taking longer than 1000ms.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -