title: How do I view the definition for a stored procedure that cannot be modified in SQL Server 2008 R2?
body: <p>I am trying to view a stored procedure that resides in a database running in SQL Server 2008 R2. I have found the stored procedure under <code>[dbName] &gt; Programmability &gt; Stored Procedures &gt; dbo.[sprocName]</code> but it has a little padlock icon next to it and when I right click on it to modify it, the modify option is grayed out.</p>
  
  <p>I then tried to access the definition by querying object in the database like this:</p>
  
  <pre><code>use [dbName];
  select * from sys.sql_modules
  where definition LIKE '%[sprocName]%'
  </code></pre>
  
  <p>This does not yield the definition for the desired stored procedure, but the query does work for stored procedures that I can already modify.</p>
  
  <p>How do I view the definition of this stored procedure without gaining modify privileges?</p>
  
  <h2>Update</h2>
  
  <p>It appears that the Sproc is in fact encrypted based on this error message:</p>
  
  <pre><code>TITLE: Microsoft SQL Server Management Studio
  ------------------------------
  
  Script failed for StoredProcedure 'dbo.[sprocName]'.  (Microsoft.SqlServer.Smo)
  
  ------------------------------
  ADDITIONAL INFORMATION:
  
  Property TextHeader is not available for StoredProcedure '[dbo].[sprocName]'. This property may not exist for this object, or may not be retrievable due to insufficient access rights.  
      The text is encrypted. (Microsoft.SqlServer.Smo)
  </code></pre>