December 2013
Intermediate to advanced
1872 pages
153h 31m
English
After you identify that a particular stored procedure is running slowly, what should you do? You might want to look at the estimated execution plan for the stored procedure, looking for table scans and sections of the plan that have a high cost percentage. But what if the execution plan has no obvious problems? This is the time you should consider using the SQL Profiler.
You can set up a trace on the stored procedure that captures the execution of each statement within it, along with its duration, in milliseconds. Here’s how:
1. Create a new trace, using the TSQL_Duration template.
2. Add the SP:StmtCompleted event from the stored procedure event class to the trace.
3. Add a filter on the Duration