Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Get stored procedure name from with a stored procedure.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-06-24 : 07:28:24
Aaron writes "Is it possible to dynamically determine the name of a stored procedure from within that same stored procedure.

While I know it isn't correct, this is what I am looking for:

---------begin dream proc----------
create proc myproc_DoSomething
@value int
AS

--This is the problem, getting the procname.
EXEC audit_proc @@ProcName
.
.
.
the rest of the procedure.
---------end dream proc----------

The @@ProcName should be some system function that would return the currently running procname, in this case "myproc_DoSomething"

Any ideas?

Aaron"

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-06-24 : 07:32:40
have a look at @@procid....you may be able to use the value returned to determine the procedure name when using the information_schema views.....
Go to Top of Page

Wanderer
Master Smack Fu Yak Hacker

1168 Posts

Posted - 2004-06-24 : 07:34:40
drop proc testprocedure
go
CREATE PROCEDURE testprocedure AS
select object_name(@@procid) AS 'ProcID'
GO
EXEC testprocedure
GO

hows that?

*##* *##* *##* *##*

Chaos, Disorder and Panic ... my work is done here!
Go to Top of Page

headyan
Starting Member

2 Posts

Posted - 2004-06-24 : 07:47:05
Thanks all. As soon as I saw the @@procid it all became so clear....
Go to Top of Page
   

- Advertisement -