Some of us when executing a Store Procedure in SQL Server want to insert a record into the table with the current procedure name that is executed (this can especially useful when the procedure name is stored in the exception tables when there is an error in the execution of the SP)
Below is the query to find the current proc name using T-SQL Script:
SELECT ISNULL(OBJECT_NAME(@@PROCID), 'MYPROC')
In the SP , we can write as
INSERT INTO Exception_Table(ProcedureName) SELECT ISNULL(OBJECT_NAME(@@PROCID), 'MYPROC')
Have a nice day !