title: Accessing the name of the currently executing stored procedure name via T-SQL?
body: <p>I need to log the stored procedure name to determine which stored procedure are being used.</p>
  
  <p>To accomplish this I am embedding an insert statement in each of the stored procedures we have to log it's usage.</p>
  
  <p>I could hard code the SP name in the INSERT statement but I am looking for an elegant way to get the current stored procedure name rather than hard coding, this is primarily to be able to search for and remove identical lines of code after the project.</p>
  
  <p>I have a table called <code>tblUsed (ID INT, dateused date, sprocused varchar(50))</code> and was planning to do an insert in each query.  </p>
  
  <pre><code>INSERT INTO [stockist].[dbo].[tblUsed]
             ([objectName])
       VALUES
             (*procname*)
  </code></pre>
  
  <p>I just need to get the name of the proc for this to work.</p>
  
  <p>If there are any other ways to accomplish this I would be happy to hear them.</p>
  
  <p>Thank you in advance.</p>