Friday, March 23, 2012

Name of running procedure

Is it possible in 2000 (or 2005) to get the name of the currently running
procedure, from inside the procedure?
I would like to write code to log procedure events, without having to change
the procedure name as I copy it from one procedure to another.
Thanks,
JayOn Tue, 18 Sep 2007 10:59:51 -0700, "Jay" <nospan@.nospam.org> wrote:
>Is it possible in 2000 (or 2005) to get the name of the currently running
>procedure, from inside the procedure?
Yes.
CREATE PROCEDURE testprocedure AS
SELECT @.@.PROCID AS 'ProcID',
OBJECT_NAME(@.@.PROCID) AS 'Procedure'
GO
EXEC testprocedure
GO
Roy Harvey
Beacon Falls, CT|||Thanks Roy.
"Roy Harvey (MVP)" <roy_harvey@.snet.net> wrote in message
news:t260f39s14nj0ph8k4iofg7i6furlusfi7@.4ax.com...
> On Tue, 18 Sep 2007 10:59:51 -0700, "Jay" <nospan@.nospam.org> wrote:
>>Is it possible in 2000 (or 2005) to get the name of the currently running
>>procedure, from inside the procedure?
> Yes.
> CREATE PROCEDURE testprocedure AS
> SELECT @.@.PROCID AS 'ProcID',
> OBJECT_NAME(@.@.PROCID) AS 'Procedure'
> GO
> EXEC testprocedure
> GO
> Roy Harvey
> Beacon Falls, CT

No comments:

Post a Comment