Oct
8
Written by:
Steve Gray
10/8/2010 2:51 PM
I can across this today in an email from http://www.sqlshare.com. If you’re reading this and you don’t subscribe to them, you need to.
@@ProcID is a SQL function that returns the name of the currently processing procedure. Here’s a small script that demonstrates it’s use
IF EXISTS (
SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE SPECIFIC_SCHEMA = N'dbo'
AND SPECIFIC_NAME = N'FP_test'
)
DROP PROCEDURE dbo.FP_test
GO
CREATE PROCEDURE dbo.FP_test
AS
select @@PROCID as ProdID,object_name(@@PROCID) as ProcName
GO
grant exec on FP_test to public
And the results look like this:

As always, I welcome your comments!