데이터베이스의 테이블 중 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;
Retrieved from http://w.databaser.net/moniwiki/wiki.php/통계정보갱신
last modified 2018-04-13 23:12:53