;WITH StatsDetails AS
(
SELECT ObjectID = o.object_id
, SchemaName = sch.name
, ObjectName = o.name
, StatsName = st.name
, StatsID = st.stats_id
, StatsDate = CONVERT(VARCHAR(30), dsp.last_updated, 120)
, Rows = dsp.rows
, RowsSampled = dsp.rows_sampled
, ModificationCounter = dsp.modification_counter /* number of modifications to the stat's
leading column that have been modified
since the last stats update
*/
, UpdateStatement = 'UPDATE STATISTICS ' + quotename(sch.name)