Re: Detect "calling" stored proc?
From: Jacco Schalkwijk (NOSPAMjaccos_at_eurostop.co.uk)
Date: 03/02/04
- Next message: Jeff: "Re: Server busy dialog"
- Previous message: MR.T: "select statement"
- In reply to: Louis: "Detect "calling" stored proc?"
- Next in thread: Brian Moran: "Re: Detect "calling" stored proc?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 2 Mar 2004 13:50:41 -0000
You can use SQL Profiler to find out by which procedure the second procedure
is called if you trace the SQL:StmtStarted or SQL:StmtCompleted events.
If you trace the following:
CREATE PROC usp_inner
AS
SELECT 1
GO
CREATE PROC usp_outer
AS
EXEC usp_inner
GO
EXEC usp_outer
GO
DROP PROC usp_outer, usp_inner
GO
You will see
-- usp_outer
EXEC usp_inner
-- usp_inner
SELECT 1
in the TextData column of your trace. The commented out bit is the calling
procedure. Even when you execute a variable procedure name, you can still
find out the calling procedure, because the calling procedure name will be
in the event before the first event that includes the called procedure's
name (like the example above)
-- Jacco Schalkwijk SQL Server MVP "Louis" <Ludek@nowhereland> wrote in message news:eTQsMmFAEHA.684@tk2msftngp13.phx.gbl... > Hi, > > Is there any way to get an object ID for the the stored procedure or trigger > that called the currently executing stored proc? > That is almost like @@PROCID will give me the ID of the currently executing > proc, but if @spCurrentProg was called from spCallingProg, > or trigCallingTrig .. then I want the object id for that calling proc / > trigger. > > This is all for debugging something on our system. > > Thanks > Louis > >
- Next message: Jeff: "Re: Server busy dialog"
- Previous message: MR.T: "select statement"
- In reply to: Louis: "Detect "calling" stored proc?"
- Next in thread: Brian Moran: "Re: Detect "calling" stored proc?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|