Query Response time check

Is there a global variable or something of the sort that would tell me how long it took to execute a query?

I need to monitor my DB response times and we have a query that runs in under 2 seconds. So we want to run this query every couple of minutes and if it takes more than 12 sec to run, we want to send an email to our DB staff...

I know that I could take a time stamp before and after then subtract but I wanted to know if there was an easier way to do it..

Thanks.

[503 byte] By [WilliamLowers] at [2007-12-24]
# 1

From an alerting aspect that is your best option. You can run profiler, but you will then need a process to get the data and send the alert.

declare @start datetime

exec ....

if datediff(ms,@start,getdate()) > 2000

RAISERROR ....

SimonS at 2007-10-8 > top of Msdn Tech,SQL Server,Transact-SQL...
# 2
Thanks...
WilliamLowers at 2007-10-8 > top of Msdn Tech,SQL Server,Transact-SQL...

SQL Server

Site Classified