In SQL Server 2016, I have a stored procedure that sends an email, which I call from various other stored procedures.
As part of that email procedure, I'd like to log the results to a table, including the name of the stored procedure that was used to call the email procedure.
If I use:
SELECT OBJECT_NAME(@@PROCID)
then all I get is the name of the email procedure, which I already know.
What I want is the name of the procedure that ran the email procedure, if that makes sense.
Is this possible?