Provide DMV to provide the call stack of stored procedures, triggers, CLR functions etc prefferable in JSON format so it is parsable.
As Erland Sommarskog says this is available but only in the "event Blocked Process Report:
<frame line="17" stmtstart="1332" stmtend="2906" sqlhandle="0x03000d00399f00558c840601a29800000100000000000000"/>
<frame line="1" sqlhandle="0x01000d00638e300f302e10ac000000000000000000000000"/>
That is, here the call stack is available. Through the sqlhandle it is possible to retrieve
the objectids of the calling procedures.
If if it's available this way, it can't be too difficult to expose this in a DMV. Only exposing the
sqlhandle would not match with my observation with permissions above, but since you probably
only want this code in a few places, this could be dealt with adding extra privs with
This is already requested in connect items 124537 and 2781373.
Steve Malcolm commented
Bob Sovers commented
This appears to be a duplicate of "Provide function to retrieve the entire call stack"