Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving stored procedures name..

Status
Not open for further replies.

MarkButler

Programmer
Joined
Feb 22, 2001
Messages
83
Location
US
I wish to create a log when scheduled procedures are run to capture some counts and totals. I want to insert a record into a log file each time the procedure is run. I wish to store the name of the stored procedure to this log file. What I am looking for is a way to determine from within the stored procedure its name.

I am looking for a function similar to the "DB_Name" function. I found the "@@ProcID" which returns an integer but how do I get from that to the name of the actual procedure or is there a function I am missing?

TIA
Mark
 

use it as an index into sysprocedures
 

sorry, sysprocedures won't give you the name - use it against sysobjects and look at the name field in sysobjects:

select name
from sysobjects
where Id = @@ProcId
 

one last shot - @@ProcId won't be enough when querying sysobjects:

select name
from sysobjects
where Id = @@ProcId
and xtype = 'P'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top