Home All Groups Group Topic Archive Search About

SP:StmtCompleted event

Author
16 Nov 2005 3:46 PM
Alexey Rokhin
How to get stored procedure's name in which statement was executed?

Author
16 Nov 2005 4:21 PM
David Gugick
Alexey Rokhin wrote:
> How to get stored procedure's name in which statement was executed?

Stored procedure statements are captured using the SP:StmtStarting/Completed
events. Individual statement statistics are in that event as well. Stored
procedure start/stop is in the SP:Starting/Completed events, but there are
no perf stats in those events. You need to use either SQL:StmtCompleted or
RPC:Completed to get the stats for the entire procedure.

--
David Gugick
Quest Software
Author
16 Nov 2005 6:43 PM
Kalen Delaney
Hi Alexey

Capture the DatabaseID and ObjectID data along with SP:StmtCompleted and
after you have that info,

SELECT db_name( <databaseID>) will show you the db. USE that db and then
SELECT object_name (<ObjectID>) to get the stored procedure name.

--
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com


Show quote
"Alexey Rokhin" <a*@hotmail.com> wrote in message
news:%232jvvSs6FHA.1188@TK2MSFTNGP12.phx.gbl...
> How to get stored procedure's name in which statement was executed?
>
>
Author
16 Nov 2005 9:08 PM
David Gugick
Kalen Delaney wrote:
> Hi Alexey
>
> Capture the DatabaseID and ObjectID data along with SP:StmtCompleted
> and after you have that info,
>
> SELECT db_name( <databaseID>) will show you the db. USE that db and
> then SELECT object_name (<ObjectID>) to get the stored procedure name.
>
>
> "Alexey Rokhin" <a*@hotmail.com> wrote in message
> news:%232jvvSs6FHA.1188@TK2MSFTNGP12.phx.gbl...
>> How to get stored procedure's name in which statement was executed?

Just to add what Kalen wrote: If you query a trace file or trace table and
use the object_name() function, you need to be aware that the function is
database-centric. That is, if you capture data from more than one database
in the trace, you must be in the context of the database of the object name
you are trying to resolve. Otherwise, you'll either get a null result or the
name of an incorrect object.

--
David Gugick
Quest Software
Author
17 Nov 2005 5:17 AM
Andrew J. Kelly
SP:StmtCompleted usually includes the sp name as a comment in the TextData.


--
Andrew J. Kelly  SQL MVP



Show quote
"Alexey Rokhin" <a*@hotmail.com> wrote in message
news:%232jvvSs6FHA.1188@TK2MSFTNGP12.phx.gbl...
> How to get stored procedure's name in which statement was executed?
>
Author
17 Nov 2005 5:49 AM
Alexey Rokhin
I forget to point I mean Profiler 2005.


Show quote
"Andrew J. Kelly" <sqlmvpnooospam@shadhawk.com> wrote in message
news:ufSjFZz6FHA.2384@TK2MSFTNGP12.phx.gbl...
> SP:StmtCompleted usually includes the sp name as a comment in the
> TextData.
>
>
> --
> Andrew J. Kelly  SQL MVP
>
>
>
> "Alexey Rokhin" <a*@hotmail.com> wrote in message
> news:%232jvvSs6FHA.1188@TK2MSFTNGP12.phx.gbl...
>> How to get stored procedure's name in which statement was executed?
>>
>
>

AddThis Social Bookmark Button