我有一个嵌套在其他几个存储过程中的存储过程。有没有办法告诉(在内部存储过程中)哪个是调用者?
CREATE PROC int_proc
AS
SELECT int_name = OBJECT_NAME(@@PROCID)
,ext_name = 'How can I tell which is the ext_proc name?'
,nestlevel = @@NESTLEVEL
GO
CREATE PROC ext_proc1
AS
SELECT ext_name = OBJECT_NAME(@@PROCID),nestlevel = @@NESTLEVEL
EXECUTE int_proc
GO
CREATE PROC ext_proc2
AS
SELECT ext_name = OBJECT_NAME(@@PROCID),nestlevel = @@NESTLEVEL
EXECUTE int_proc
GO
EXEC ext_proc1
EXEC ext_proc2
我正在使用 SQL-Server 2005