Method for querying the last Rebuild time of SQL Server Index, sqlrebuild

Source: Internet
Author: User

Method for querying the last Rebuild time of SQL Server Index, sqlrebuild

A friend has a Job that usually stops executing a Rebuild Index and asked me if I can check which indexes have been rebuilt. We thought that Sys. index or Sys. objects would store similar information and the result was not found.
 
I checked from the Internet that SQL Server does not store similar information. However, because Rebuild Index automatically updates the statistics, the update time of the statistics is available. Therefore, we can estimate the time based on the statistical information.
Because the update of statistical information may also be an update that reaches the updated threshold value, it is not very accurate.
 
The specific script is as follows:

SELECT OBJECT_NAME (object_id) [TableName], name [IndexName], STATS_DATE (object_id, stats_id) [LastStatsUpdate] FROM sys. statsWHERE name not like '_ WA %' -- AND STATS_DATE (object_id, stats_id) is not nulland objectproperty (object_id, 'ismsshipped ') = 0 -- Query user-defined order by TableName, indexName ----- code from: http://stackoverflow.com/questions/2831293/tsql-know-when-index-rebuild-reorg-or-updatestatistics-was-last-run-on-sql-ser

You can add filter conditions based on your own.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.