title: Public stored procedure to access sys.dm_db_index_usage_stats
body: <p>I'm trying to make available some part of sys.dm_db_index_usage_stats view to all users in my SQL Server. The goal is to provide that information without breaching SQL Server security.</p>
  
  <p>I'm not an DB expert, but I have prepared this code:</p>
  
  <pre><code>CREATE PROCEDURE dbo.[LastTableUpdate]   
      @Table nvarchar(50)   
  WITH EXECUTE AS OWNER 
  AS   
  SELECT 
      DB_NAME(database_id) as 'Database', 
      OBJECT_NAME(object_id) As TableName, 
      max(last_user_update) as user_update,
      max(last_system_update) as system_update
   FROM sys.dm_db_index_usage_stats WHERe database_ID=DB_ID() AND object_id=OBJECT_ID(@Table)
   GROUP BY database_id, object_id
  </code></pre>
  
  <p>Next I grant privileges</p>
  
  <pre><code>GRANT EXEC ON dbo.[LastTableUpdate] TO PUBLIC
  </code></pre>
  
  <p>But when I'm calling it got</p>
  
  <pre><code>Msg 15562, Level 16, State 1, Procedure LastTableUpdate, Line 5
  The module being executed is not trusted. Either the owner of the database of the module needs to be granted authenticate permission, or the module needs to be digitally signed.
  </code></pre>
  
  <p>Can you assist me, how should I proceed? As I have mentioned - my goal is to keep DB as secure as possible.</p>