title: What tables were accessed last
body: <p>I want to know the top N tables that were accessed. I only got for databases and most of the links in google address last date access for a particular table.</p>
  
  <pre><code>SELECT DatabaseName, MAX(LastAccessDate) LastAccessDate
  FROM
      (SELECT
          DB_NAME(database_id) DatabaseName
          , last_user_seek
          , last_user_scan
          , last_user_lookup
          , last_user_update
      FROM sys.dm_db_index_usage_stats) AS PivotTable
  UNPIVOT 
      (LastAccessDate FOR last_user_access IN
          (last_user_seek
          , last_user_scan
          , last_user_lookup
          , last_user_update)
      ) AS UnpivotTable
  GROUP BY DatabaseName
  HAVING DatabaseName NOT IN ('master', 'tempdb', 'model', 'msdb')
  ORDER BY 2
  </code></pre>
  
  <p>Now I need this for tables. Any idea or link, please?</p>