Wednesday, 22 July 2020

[SQL Server] Index created date, Index last modified date

[SQL Server] Index created date, Index last modified date

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

(KOR) AI와 지속 가능한 엔지니어링 — 생성은 빠르게, 검증은 철저하게

영어 원문 : https://www.linkedin.com/pulse/ai-sustainable-engineering-generate-fast-verify-thoroughly-yoon-hclqf/ [공지 / 면책 조항] 이 글에 표현된 모든 견해는 전...