How do we know the index created date or index last modified date?
The correct answer (so far) is "WE DON'T KNOW!"
You can get created date for PK(Primary key), FK(Foreign key) and UK(Unique key) by the following script.
SELECT OBJECT_NAME(o.parent_object_id) AS TableName, i.NAME AS 'Index Name', o.create_date FROM sys.indexes i INNER JOIN sys.objects o ON i.NAME = o.NAME WHERE o.is_ms_shipped = 0 AND o.type IN('PK', 'FK', 'UQ') AND OBJECT_NAME(o.parent_object_id) = 'Employee' ORDER BY OBJECT_NAME(o.parent_object_id) ;
You can also get the stats created date for the indexes by the following script.
SELECT 'HumanResources.Employee' AS TableName, Name AS IndexName, STATS_DATE(object_id, index_id) AS IndexStatsDate FROM sys.indexes WHERE object_id = OBJECT_ID('HumanResources.Employee');
No comments:
Post a Comment