longbloke69
asked on
Dynamically getting the callee name of a stored procedure
I am calling a Error Handling/reporting stored procedure from within another stored proc.
I would like the error handling/reporting stored procedure to record which stored procedure it was called from, is this possible?
I would like the error handling/reporting stored procedure to record which stored procedure it was called from, is this possible?
ASKER
Yea thats what I am doing now, but, I would like to get the name automatically, so i can just run the stored procedure in every procedure i see fit, without needing to update that parameter. Just a streamlined way of doing it!
I didn't find any option for that since a procedure can be called anywhere either from the application or from query analyzer like that. Anyhow will check it revert if I find some possible solutions
I don't know of any way to get that info in SQL Server.
ASKER
Its just like in JavaScript, where you can check what the callee is named: Function.arguments.callee or window.callee.
Thats practically impossible.
Assume an user is executing procedure from Enterprise Manager.
Another from SSMS.
Another from Toad.
Another from a master procedure.
Another from a nested level 2 procedure.
Etc.,
Hence its practically not possible to identify the user without using a Parameter for that query
And hence the answer for your question is No.
Assume an user is executing procedure from Enterprise Manager.
Another from SSMS.
Another from Toad.
Another from a master procedure.
Another from a nested level 2 procedure.
Etc.,
Hence its practically not possible to identify the user without using a Parameter for that query
And hence the answer for your question is No.
ASKER
The Procedure I am calling will only ever be called from another stored procedure, and it's that stored procedure that I would like to identify, not the user.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
Ideal way is to have a log table and insert records into it each and every time, a procedure is called out.