Sqlserver-dba.com

Subscribe

Subscribe to RSS feed  Follow @jackvamvas - Twitter

Enjoy this post? Enter your email address for updates on new posts:

Delivered by FeedBurner

Email +Jack Vamvas at jack@sqlserver-dba.com

SQLServer-DBA.com Links

Subscribe to newsletter

Dba_db2_button

Powered by TypePad
SQL Server - Index missing Statistics

02 January,2011 by Jack Vamvas

SQL Index Statistics missing - If there is a requirement to view a list of indices and to assess the last time the statistics were updated ,this script will help.

The STATS_DATE resturns the date the statistics for the specific index were last updated - the 2 arguments are table_id and index_id.The STAS_DATE could also be used in WHERE clause

The statblob column - is the Statistics binary large object(BLOB). Therefore the DATALENGTH (si.statblob) returns the number of bytes in for that column

 

 




SELECT LastTimeUpdated = STATS_DATE(si.id, si.indid)

,TableName = object_name(si.id)

,Name = RTRIM(si.name)

,Size = DATALENGTH (si.statblob)


FROM sysindexes si WITH (nolock)

WHERE OBJECTPROPERTY(si.id, N'IsUserTable') = 1


order by LastTimeUpdated, tablename

Author: Jack Vamvas (http://www.sqlserver-dba.com)

Enjoy this post? Enter your email address for updates on new posts:

Delivered by FeedBurner

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer