Partilhar via


STATS_DATE (Transact-SQL)

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

Topic link iconTransact-SQL Syntax Conventions

Syntax

STATS_DATE ( table_id , index_id )

Arguments

  • table_id
    Is the ID of the table used.
  • index_id
    Is the ID of the index used.

Return Types

datetime

Exceptions

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.

Remarks

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

Examples

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

See Also

Reference

System Functions (Transact-SQL)
WHERE (Transact-SQL)
CREATE STATISTICS (Transact-SQL)
UPDATE STATISTICS (Transact-SQL)

Other Resources

Index Statistics

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

17 July 2006

New content:
  • Added the Exceptions section.