SQL Server Articles

Submit Article
Home » Articles » SQL Server » System FunctionsRSS Feeds


Posted By: Sarita Patel     Category: SQL Server     Views: 2170

This article explains about STATS_DATE function in sql server with examples.

STATS_DATE function returns the date of the last updated statistics for the specified index.

Syntax of STATS_DATE Function :

STATS_DATE ( table_id, index_id )

table_id is an id of table.

index_id is an id of index. 

Return type of STATS_DATE function is a datetime.

Examples of STATS_DATE Function :

Example 1 : Use of STATS_DATE function in select clause 

SELECT  i.id AS IndexID, i.name AS IndexName, STATS_DATE(i.id, i.indid) AS StatsDate
FROM     sysobjects o INNER JOIN sysindexes i ON o.id = i.id

IndexID     IndexName                                     StatsDate
4              clust                                               2005-10-14 01:36:26.140
5              clust                                               2005-10-14 01:36:26.140
5              _WA_Sys_00000003_00000005       2008-03-24 17:26:17.247
5              _WA_Sys_00000004_00000005       2008-03-24 17:26:17.263
7              clust                                               2005-10-14 01:36:26.140
7              _WA_Sys_00000002_00000007       2008-03-24 16:11:57.380
7              _WA_Sys_00000003_00000007       2008-03-24 16:11:57.380

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


Didn't find what you were looking for? Find more on STATS_DATE Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of STATS_DATE Function is from United States.
View All Articles

Related Articles and Code:

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!