一危磯伎れ 企 譴 21% 伎 row螳 企磯 糾 覲願 一危 蟆...
set nocount on
set statistics io off
declare
@tname varchar(255)
, @sql varchar(2000);
declare cur cursor for
select distinct
c.name + '.' + object_name(b.object_id)
from sys.sysindexes a
inner join sys.objects b
on a.id = b.object_id
inner join sys.schemas c
on b.schema_id = c.schema_id
where a.rowcnt / a.rowmodctr * 100 >= 21
and a.rowmodctr > 0
and a.id > 100
and a.rowcnt > 1000000
and c.name not in ('temp')
and b.type = 'U'
open cur;
fetch next from cur into @tname;
while @@FETCH_STATUS not in (-1, -2)
begin
set @sql = 'update statistics ' + @tname
exec(@sql)
print @sql
fetch next from cur into @tname;
end
close cur;
deallocate cur;