Pages

Sunday, August 12, 2012

Find out the statistics update datetime in SQL Server

How to find the updated data and time of the statistics in the database of SQL Server

Statistisc play a vital role the performance of the database.

If statistics are not updated then there might be a considerbly slow in the pace of queries running againt the database.

Generally every DBA will keep "Auto Statistics" option as "ON"

Healthy tracking of statisitcs is important and good practise.

Below query gives you the details of the statistics updated date and time:

Use DBNAME
Go
select
name ,stats_date(OBJECT_ID,INDEX_ID) statsdate from sys.indexes where object_id IN (select  object_id from sys.objects where type not in ('S'))and
 name is NOT NULL
IF found statistisc are not updated, then execute the below to update all the statistics in the database

EXEC sp_updatestats;
If, any particular statistics needs to be updated

then

Use DBNAME
Go
UPDATE STATISTICS dbo.tablename
Go