Skip to content

Instantly share code, notes, and snippets.

@JCKodel
Created August 20, 2018 23:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JCKodel/1cfe5c7a9b08347d51246d8c96a936a1 to your computer and use it in GitHub Desktop.
Save JCKodel/1cfe5c7a9b08347d51246d8c96a936a1 to your computer and use it in GitHub Desktop.
Obtendo a última data de alteração de cada tabela
SELECT
q.tableName
,MAX(q.lastUpdate) AS lastUpdate
FROM
(
SELECT
s.name + '.' + t.name AS tableName
,ISNULL(u.last_user_update, '2000-01-01') AS lastUpdate
FROM sys.tables AS t
INNER JOIN sys.schemas AS s ON s.schema_id = t.schema_id
LEFT JOIN sys.dm_db_index_usage_stats AS u ON u.object_id = t.object_id
) q
GROUP BY q.tableName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment