Function: stat_dt
Author: Geoffrey Rommel
Purpose: This UDF converts the first 4 bytes of a FieldStatistics or
IndexStatistics column to an ordinary DATE data type. This
can be used to find the date on which stats were last collected.
Converting the first 8 bytes to TIMESTAMP is left as an
exercise for the reader. ;-)
Example:
select stat_dt(FieldStatistics), DatabaseName, TableName, ColumnName
from DBC.ColumnStats
where FieldStatistics is not null
order by 1;
|