November 26, 2010

Get the Current Stored Procedure Name in SQL Server

I see a lot of developers asking how to get the currently executing Stored Procedure name. This is probably for logging the stored procedures when they are executed.

Here’s a very simple way. I have added comments to explain the code

Current Stored Procedure

Observe the built-in object_name(@@procid) function which returns the Stored Procedure name


Current Stored Procedure

Did you like this post?
kick it on
subscribe via rss subscribe via e-mail
print this post follow me on twitter

About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal



0 Responses to "Get the Current Stored Procedure Name in SQL Server"

Copyright © 2009-2014 All Rights Reserved for by Suprotim Agarwal | Terms and Conditions