Get the name of the stored procedure for error reporting. This name will be passed to RAISERROR.
Example Code:
CREATE PROCEDURE ExampleSP
AS
BEGIN
DECLARE @spName sysname
SELECT @spName = Object_Name(@@ProcID)
RAISERROR('The name of this procedure is %s.', 1, 1, @spName)
RETURN(0)
END
GO
EXEC ExampleSP
Example Output:
Msg 50000, Level 1, State 50000
The name of this procedure is ExampleSP.