Learn more about SQL Server tools

mssqltips logo

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Scripts          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories


SQL Server Video to return the procedure name using @@PROCID

By:   |   Last Updated: 2014-07-14   |   Comments   |   Related Tips: More > Stored Procedures


Enter your business email address to
get free SQL Server tips.

Problem / Solution

The input parameter @@PROCID returns the object_id of the current stored procedure, function or trigger. This video shows how to use @@PROCID in a stored procedure to get the schema and procedure name. It also corrects a misperception that appears in some places on the internet that @@PROCID would let you know which procedure initiated a trigger. It doesn't do that and that problem is demonstrated.

Key Learning Items
  • Using @@PROCID with OBJECT_NAME
  • How to use @@PROCID to always return the correct name of the procedure
  • What happens when you use @@PROCID inside of a trigger
Read Companion Tip
Click Here

Last Updated: 2014-07-14

get scripts

next tip button

About the author
MSSQLTips author Andy Novick Andy Novick is a SQL Server Developer in the Boston area with 25 years of database and application development experience.

View all my tips

Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Email me updates 

Signup for our newsletter
 I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.


Learn more about SQL Server tools