Current Procedure Name

  • Is there any way to get a procedure name from within the procedure, without

    hardcoding it. I am trying to write a generic error reporting procedure, that

    would be used by all the applications. To track down which procedure is

    reporting the error, I need to pass the procedure name as a parameter. Using

    Object_Name would not work since it needs a parameter. I essentially need something

    like this that takes no parameters, and returns the current procedure name.

    thanks.

  • @@PROCID will return the id of the current stored procedure. You can then look this id up in the sysobjects table to find the procedure name.

    regards

  • Though its not recommended, but u can get the proc names from sysobjects in master database. Good luck.

  • OBJECT_NAME(@@PROCID)

    --Jonathan



    --Jonathan

  • That just works perfect.

    Thank You All.

Viewing 5 posts - 1 through 4 (of 4 total)

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