Dynamically Getting Stored Proc Name

  • I have a quick question and I am hoping the MVP's and Expect will help me here.

    I am hoping T-SQL have a function that will allow you to get the name of a stored procedure while the code within the procedure is running.

    what I mean is having a procedure name "A", to call this procedure you must know the name of it (that given) now after calling the procedure, I want to dynamically retrieve the name of the procedure ("A") without hard coding it so that when the procedure name changes, I will not have to go in the code and change lines of code.

    Is this possible? if it is how it is done? Any sample code available? HELP.

    Thanks.

  • create proc spname as

    select object_name(@@PROCID) procname

    go

    exec spname

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply