iT邦幫忙

0

[MS SQL] 取SQL Server Table最後一次異動日期

這些table還有在用嗎?
怎麼取得Table最後一次異動日期?
如果有建索引,就可以用這個方法查閱

SELECT TOP 100 PERCENT TABLENAME,LASTUPDATED FROM
(
SELECT B.NAME AS 'TABLENAME', MAX(STATS_DATE (ID,INDID)) AS LASTUPDATED
FROM sys.sysindexkeys AS A
INNER JOIN sys.objects AS B ON A.ID = B.OBJECT_ID
WHERE B.TYPE = 'U' AND STATS_DATE (ID,INDID) IS NOT NULL
and B.NAME in ('ooo','xxx')
GROUP BY B.NAME
) AS A
order by LASTUPDATED desc

Ref
https://www.google.com.tw/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0ahUKEwje6f_R6ODXAhVGabwKHeOnDK0QFggzMAI&url=http%3A%2F%2Fyiinjiun.blogspot.com%2F2014%2F12%2Fms-sql-table.html&usg=AOvVaw3iCVIbgP2EZrljecloVfwb


尚未有邦友留言

立即登入留言