SQL Server – Get Proc Name From Within Proc

Want to get the name of a SQL Server stored procedure from with the procedure itself? No problem! This quick T-SQL script is all you need.


Need the schema as well?


I've found this particularly helpful when logging stored procedure execution to an audit table.

p.s. I think this goes without saying but if you need only the object id the following complicated query can be used:


Categorized as Scripts

By Phil Steffek

Phil Steffek is a professional sumo wrestler who is hoping to represent the U.S. in the next Olympics. During the off season Phil is a Data Architect working on transactional databases, data warehouse implementations, and all aspects of business intelligence. Also, Phil is not really a sumo wrestler. You can get to know a bit more about my non-sumo doings by checking out my LinkedIn Page

Leave a comment

Your email address will not be published.