Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Track Long Running Queries

By Ferguson,

SQL2000 only.

We use the attached script to schedule a SQL Agent job that sets up a Profile trace looking for long queries, and hourly imports them into a table.  This way we can historically (but with some degree of real time) look to see what queries put a load on the system.  We then allow people to query this directly or through a simple ASP web page.

There's a lot of code inside that should be customized - how often you want it to run (you can also run it any time from SQL Agent or directly), how long to keep data, what you consider long-running, where to keep the files, etc.  Think of it as a framework.

You may want to skip the scripted job creation and do it manually with your own criteria (e.g. this one reports errors to an operator DW ERRORS you will likely not have).

Note that it puts the procedure and table in MASTER.  Some won't like that, so don't just run this until you decide where you want it.

Feedback welcomed to Ferguson@chaslevy.com

Total article views: 1325 | Views in the last 30 days: 4
 
Related Articles
FORUM

query

query

FORUM

Query

Query

FORUM

query

query

FORUM

Query

Query

FORUM

Query

Query

 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones