See what sp_execute does

In my MS SQL profile, I see a lot of these small queries.

exec sp_execute 1, @ p0 = 15954

I know that this theoretically works, that it executes a previously created request and passes a specific parameter. But the problem is that I'm not sure what causes these requests.

Is there a way to see the TSQL contents of these queries?

+7
source share
3 answers

It looks like it is executing a prepared request. It's one thing to look at the profiler trace to see if you can find the sp_prepare requests that generate this particular descriptor.

Another option is to query system views to find the body of the text.

This will give you a request if it is currently running

select text from sys.dm_exec_requests cross apply sys.dm_exec_sql_text(plan_handle) where session_id = <SPID FROM PROFILER> 
+8
source

In Sql profiler, I use Event StoredProcedure -> SP: CacheHit. I read about it in the link . SQL capture: StmtCompleted and RPC: completed DIDNT catches sp_execute parameter

+8
source

The answer in SQL Server 7.0 and later "just turned on tracing in SQL Profiler."

Perhaps you have an SQL Profiler. If so, use it.

Or maybe you have a newer version of MSSQL Express (which no longer binds SQL Profiler). If yes, try the following:

-3
source

All Articles