Parent procedure or function name

how to get parent procedure name in child procedure name
say
proc A
(
call Procc B
 )

proc B
(
--NEED PROC A NAME
)

LVL 4
jindalankushAsked:
Who is Participating?
 
RiteshShahConnect With a Mentor Commented:
You can't predict which procedure has called your PROC B. it could be called from PROC A or may be from PROC D or C anywhere. you can have parameter so that you can decide which procedure has called PROC B.
0
 
RiteshShahCommented:
create proc b (@procName varchar)
as
begin
select @procname
end


create proc a
as
begin
exec b 'a'
end

create proc c
as
begin
exec b 'c'
end


--run SP and check.
exec a

exec c
0
 
jindalankushAuthor Commented:
i need that proc name either its a proc A or proc D.
i can not pass any parameter
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
RiteshShahCommented:
well in that case, I don't think so it is possible.
0
 
jindalankushAuthor Commented:
how can we find parent procedure name
0
 
RiteshShahCommented:
as I told you before also, it is not possible with the way you want. SQL Server is RDBMS not Object Oriented Language.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.