SQL Alert when stored procedure executes for too long

前端 未结 6 1530
旧时难觅i
旧时难觅i 2021-01-13 07:32

I would like to set up a SQL Server 2008 Alert to notify me when any procedure executes for 1 second or longer (just an example).

Any ideas?

EDIT:

Ok

6条回答
  •  忘掉有多难
    2021-01-13 07:41

    You can log slow running queries use SQL Profiler, but that won't help you with an alert, specifically. (I suppose you could log to a File or to a database table, and have something else "listen" and raise an alert).

    In case you are not familiar with SQL Profiler here are the steps:

    You should run SQL Profiler on something other than the server itself.

    Start with the SQLProfilerTSQL_Duration template

    Set the Filter : Duration : "Greater than" to 1000 (milliseonds)

    In the filters you can restrict the Database, Login, or similar if necessary.

    In the Events you can restrict to just SProcs (default also includes SQL statements)

提交回复
热议问题