After catching some data in a SQL Profiler session, I can almost always see a second entry of type RPC:Completed for each query using a sp_executesql statement. I know that this is done to create re-usable execution plan by reducing the query with parametrization.


exec sp_executesql N'SELECT s.* FROM s WHERE s.C= @O',
@O uniqueidentifier',

Duration: 10 ms

Next entry:


Duration: 10 ms

Looking at the total sum(Duration) of the profiler events, do I have to count both of those? The query was executed once, so 10 ms was the correct result. Instead the total result is 20 ms, with I think is just WRONG and a program-error of Profiler. Do I have to filter one of them away anyhow and how?

  • 2
    The RPC completed event will the total for the entire request. What is the event class of the SELECT statement?
    – Dan Guzman
    Aug 18, 2015 at 12:09
  • Looks like those are of type SP:StmtCompleted ( I have saved the results to a table and there is a column EventClass. Values of the SELECT Statements is 45. I have joined this with sys.trace_events.trace_event_id)
    – Magier
    Aug 18, 2015 at 13:23

1 Answer 1


You don't have to count both. As you see, you get an rpc completed for sp_executesql. Your Select which shows up as StmtCompleted is a "subtask" of the rpc. The SQL trace already has the sum of all statements inside a rpc summed up for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.