Thank you Sergey! this is what I was looking for. Your help is always very much appriciated.
Rollin
>See
SQL Server 2005 and 2008 - Backup, Integrity Check and Index Optimization . I'm using 'Integrity Check and Index Optimization' part of it. Didn't have time to see if I want to use 'Backup' part as well.
>
>>In SQL 2000 (and still in SQL 2005 - but not being continued) DBCC SHOWCONTIG has been used to capture index statistics. With a cursor, all indexes of all tables (of all DBs) could have their stats extracted with one procedure.
>>
>>In SQL 2005, sys.dm_db_index_physical_stats is the recommended method. This gives the information differently. Wtih all arguments set to NULL, all of the index information can be selected without the need for a cursor. It gives database_id and object_id, though, not the names.
>>
>>My question is this: What would be the best way to have a procedure that uses
>>
>> ALTER INDEX ALL ON ... REORGANIZE and
>> sys.dm_db_index_physical_stats
>>
>>to update all indexes (on all tables, and all DBs) that are more than 20% fragmented??
>>
>>Your help is greatly appreciated.
Thank You
Rollin Burr
Politicians and diapers have one thing in common. They should both be changed regularly, and for the same reason.