DEFINITIONS

Definitions More Info.
Definition ID880
TitleSQL
CategoryNOTES
DefinitionSTATISTICS INFORMATIION
Definition Descriptionselect
schemas.name as table_schema,
tbls.name as name,
i.name as statistics_name,
i.id as table_id,
i.indid as statistic_id,
i.groupid,
i.rowmodctr as modifiedRows,
(select max(rowcnt) from sysindexes i2 where i.id = i2.id and i2.indid < 2) as rowcnt,
convert(DECIMAL(18,8), convert(DECIMAL(18,8),i.rowmodctr) / convert(DECIMAL(18,8),(select max(rowcnt) from sysindexes i2 where i.id = i2.id and i2.indid < 2))) as ModifiedPct,
stats_date( i.id, i.indid ) as lastStatsUpdate,
'False' as Processed
into ##updateStatsQueue
from sysindexes i
inner join sysobjects tbls on i.id = tbls.id
inner join sysusers schemas on tbls.uid = schemas.uid
inner join INFORMATION_SCHEMA.TABLES tl
on tbls.name = tl.TABLE_NAME
and schemas.name = tl.table_schema
and tl.table_type='BASE TABLE'
where 0 < i.indid and i.indid < 255
and table_schema <> 'sys'
and i.rowmodctr <> 0
and (select max(rowcnt) from sysindexes i2 where i.id = i2.id and i2.indid < 2) > 0
order by 8 desc

select * from ##updateStatsQueue
order by 8 desc

drop table ##updateStatsQueue

exec sp_updatestats
RecordBycunay
Record Date08-09-2018 11:13:50
Düzenle
Kopyala
Sil