Dec 7, 2014

How to get current stored procedure name or ID in SQL Server

Some time we need to display to current or running stored procedure name in sql server. It is due to displaying error messages or to print some message. Problem with hard coded stored procedure name is that if procedure name has been changed then we will have t update the name each and every places.  Best way we can do it by using meta data function.

Script to get the current or running stored procedure name inside stored procedure:

SELECT OBJECT_NAME(@@PROCID) AS ProcName


We must have to write above script inside the stored procedure.

No comments:

Post a Comment