Help with extended event sp_statement_completed data.

The sp_statement_completed returns a column called object_type. When the contents of that column are in (PROC, FUNCTION, TABFUNC) the object_id returns a non null value with OBJECT_NAME(object_id) function. When the object_type column values are in (PREPARED, ADHOC) the OBJECT_NAME function returns null. This event (sp_statement_completed) identifies statements in a procedure that have ended so how do I identify what procedure these prepared and adhoc statements are in?

Where can I find a complete description of the values in the object_type column?

September 9th, 2015 2:40pm

Look for a subsequent SP:StmtCompleted with a lower NestLevel for the stored procedure statement that calls the dynamic query.  That one will be associated with stored procedure's ObjectID.

eg

create procedure foo1
as
begin 
exec ('select COUNT(*) FROM SYS.OBJECTS a; select COUNT(*) FROM SYS.OBJECTS a;')
end

generates the following events when executed:

David

Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 4:45pm

That sounds great. I will try it in the AM.

That also likely answers my next as yet unasked question, What is the nest level?

Are the columns returned by this event clearly or even poorly document anywhere?

Thanks

September 9th, 2015 7:19pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics