RPC:Completed,sp:Stmtcompleted, SQL:BatchCompleted and SQL:stmtCompleted

  • 892717952

    SSC-Addicted

    Points: 453

    what are their differences among EventClass of RPC:Completed,sp:Stmtcompleted, SQL:BatchCompleted and SQL:stmtCompleted under SQL Profiler ? and what time does it occur for these four events ? thanks!

    Attachments:
    You must be logged in to view attached files.
  • Erland Sommarskog

    SSC-Insane

    Points: 23839

    Batches can be submitted in two ways to SQL Server. When you run a batch of one or more queries from SSMS, that will always result in an SQL:BatchCompleted. That is, in this case the full batch is sent as  text.

    But a call to a store procedure can also be done as a remote procedure call, RPC. An application sends the name of the stored procedure and the parameters in binary format. The procedure can be sp_executesql, which is used for a parameterised statement.

    The distinction between the two is not that important, and when profiling I typically always include both events. An application is likely to mix both, as not all statements are parameterised.

    The two StmtCompleted give you individual statements within the procedure or batch submitted. I think that SP:StmtCompleted is when the statement is inside an SP, and SQL:StmtCompleted is when it is in an ad-hoc batch. Again, the difference is not that important, and trace both.

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

  • 892717952

    SSC-Addicted

    Points: 453

    Dear Erland Sommarskog, thanks for you kind help!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply