Permalink
Browse files

fix last table access bug

  • Loading branch information...
gboge committed Apr 11, 2017
1 parent 487eb73 commit b05daace892a3424f3d60e8a31a086e06beea23c
Showing with 2 additions and 0 deletions.
  1. +2 −0 KDatabase.cs
View
@@ -386,6 +386,7 @@ public static DataTable GetLastAccessByTable(this smo.Database d)
, last_user_lookup
, last_user_update
FROM sys.dm_db_index_usage_stats (NOLOCK)
+ WHERE database_id = DB_ID()
)
SELECT MAX(last_read) AS last_read
, max (last_write) as last_write
@@ -424,6 +425,7 @@ UNION all
FROM sys.tables t (NOLOCK)
INNER JOIN sys.schemas s (NOLOCK) ON t.schema_id = s.schema_id
LEFT JOIN #TEMP temp (NOLOCK) ON t.object_id = temp.object_id
+
ORDER BY [Last Access] DESC
DROP TABLE #TEMP").Tables[0];

0 comments on commit b05daac

Please sign in to comment.