If I run this query on our system:
SELECT STATS_DATE(t.object_id, s.stats_id) AS stdate, * from sys.stats s WITH (NOLOCK) INNER JOIN sys.tables t WITH (NOLOCK) ON t.object_id = s.object_id WHERE t.name LIKE 'mytable%'
I sometimes see that the
stats_date function returns NULL.
This should not be possible according to BOL, except if there is an error.
It does not state which error.
The table is quite big, 11 billion rows. If I run:
UPDATE STATISTICS fct.mytable ( pk_mytable)
stats_date comes back again as not null.
Why is the date null, and how can I prevent that?
It is only the stats for the primary key that is NULL.
If I run:
DBCC SHOW_STATISTICS ('fct.MyTable', 'IX_MyTableID')
it comes back with the 3 result sets that I expect. If I run:
DBCC SHOW_STATISTICS ('fct.MyTable', 'PK_MyTable')