/*
테이블별 인덱스에 대한 통계가 마지막으로 업데이트된 날짜 찾기
이종희 2003.10.
정원혁 2004.8.
*/
SELECT USER_NAME( OBJECTPROPERTY( i.id, 'OwnerID' ) ) AS Owner
,OBJECT_NAME( i.id ) AS [Table]
, i.name AS [Index]
,CASE INDEXPROPERTY( i.id , i.name , 'IsClustered') WHEN 1 THEN 'Y' ELSE '' END AS IsClustered
,CASE INDEXPROPERTY( i.id , i.name , 'IsUnique' ) WHEN 1 THEN 'Y' ELSE '' END AS IsUnique
,STATS_DATE( i.id , i.indid ) AS LastUpdatedDate
,dPages * 8. /1024 AS MB
FROM sysindexes AS i
WHERE OBJECTPROPERTY( i.id, 'IsMSShipped' ) = 0
AND 1 NOT IN ( INDEXPROPERTY( i.id , i.name , 'IsStatistics' )
, INDEXPROPERTY( i.id , i.name , 'IsAutoStatistics' )
, INDEXPROPERTY( i.id , i.name , 'IsHypothetical' ) )
AND i.indid BETWEEN 1 AND 250
-- AND dPages > 100 --작은 크기 테이블 무시
AND (STATS_DATE( i.id , i.indid ) < GETDATE() - 15
OR STATS_DATE( i.id , i.indid ) IS NULL) --15일 이전까지도 업데이트 안된 것
ORDER BY Owner, [Table], [Index]
테이블별 인덱스에 대한 통계가 마지막으로 업데이트된 날짜 찾기
이종희 2003.10.
정원혁 2004.8.
*/
SELECT USER_NAME( OBJECTPROPERTY( i.id, 'OwnerID' ) ) AS Owner
,OBJECT_NAME( i.id ) AS [Table]
, i.name AS [Index]
,CASE INDEXPROPERTY( i.id , i.name , 'IsClustered') WHEN 1 THEN 'Y' ELSE '' END AS IsClustered
,CASE INDEXPROPERTY( i.id , i.name , 'IsUnique' ) WHEN 1 THEN 'Y' ELSE '' END AS IsUnique
,STATS_DATE( i.id , i.indid ) AS LastUpdatedDate
,dPages * 8. /1024 AS MB
FROM sysindexes AS i
WHERE OBJECTPROPERTY( i.id, 'IsMSShipped' ) = 0
AND 1 NOT IN ( INDEXPROPERTY( i.id , i.name , 'IsStatistics' )
, INDEXPROPERTY( i.id , i.name , 'IsAutoStatistics' )
, INDEXPROPERTY( i.id , i.name , 'IsHypothetical' ) )
AND i.indid BETWEEN 1 AND 250
-- AND dPages > 100 --작은 크기 테이블 무시
AND (STATS_DATE( i.id , i.indid ) < GETDATE() - 15
OR STATS_DATE( i.id , i.indid ) IS NULL) --15일 이전까지도 업데이트 안된 것
ORDER BY Owner, [Table], [Index]