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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure Name from within stored proc 1

Status
Not open for further replies.

ISPrincess

Programmer
Feb 22, 2002
318
US
I have the need to insert the name of the stored proc doing the insert into a table, but would like to make the code alittle more reusable. so rather than


Insert into mytable (ProcessName)
values('spThisStoredProcName')

I was hoping there was a way to get that from within the stored procedure (in case they change it or someone would like to copy some code from it). IE: does SQL have a command that can return that?

Insert into mytable (ProcessName)
values(@StoredProcName)


Any help would be greatly appreciated.


PH
I was walking home one night and a guy hammering on a roof called me a paranoid little weirdo.
In morse code.
-Emo Phillips
 
IIRC this is the closest shot:
Code:
select name from sysobjects where id = @@procid
 
Thank you. After checking around alittle more (sorry) i went with something similar to Vongrunt's reply:

SELECT @ProcName = Object_Name(@@ProcID)



PH
I was walking home one night and a guy hammering on a roof called me a paranoid little weirdo.
In morse code.
-Emo Phillips
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top