Is it possible to find out who called the store procedure ?, I use the following query to determine the amount of execution, etc., but I canβt determine which task / trigger / process calls it. Any ideas on this
SELECT a.execution_count ,OBJECT_NAME(objectid) Name,
(CASE WHEN a.statement_end_offset = -1
THEN
len(convert(nvarchar(max), b.text)) * 2
ELSE
a.statement_end_offset
END - a.statement_start_offset)/2 ) ,b.dbid ,dbname = db_name(b.dbid) , b.objectid
,a.creation_time,a.last_execution_time,a.*
FROM sys.dm_exec_query_stats a CROSS APPLY sys.dm_exec_sql_text(a.sql_handle) as b
WHERE OBJECT_NAME(objectid) = 'Rebuild_Indexes' ORDER BY a.last_execution_time
ESCquery_text = SUBSTRING(b.text,a.statement_start_offset/2,
source
share