Export (0) Print
Expand All
Expand Minimize

STATS_DATE (Transact-SQL)

Updated: 17 July 2006

Returns the date that the statistics for the specified index were last updated.

Topic link icon Transact-SQL Syntax Conventions


STATS_DATE ( table_id , index_id )

table_id

Is the ID of the table used.

index_id

Is the ID of the index used.

datetime

Returns NULL on error or if a caller does not have permission to view the object.

In SQL Server 2005, a user can only view the metadata of securables that the user owns or on which the user has been granted permission. This means that metadata-emitting, built-in functions such as STATS_DATE may return NULL if the user does not have any permission on the object. For more information, see Metadata Visibility Configuration and Troubleshooting Metadata Visibility.

System functions can be used in the select list, in the WHERE clause, and anywhere an expression can be used.

The following example returns the date of the last time that the statistics were updated for the specified object.

USE AdventureWorks;
GO
SELECT name AS index_name, 
    STATS_DATE(object_id, index_id) AS statistics_update_date
FROM sys.indexes 
WHERE object_id = OBJECT_ID('Person.Address');
GO

Release History

17 July 2006

New content:
  • Added the Exceptions section.

Community Additions

ADD
Show:
© 2014 Microsoft