SQLUSA

Microsoft SQL Server 2000 Best Practices

How to generated DBCC SHOWCONTIG for all the indexes?

 

Execute the following script in Query Analyzer to generated >dbcc showcontig< commands for all the indexes:

use DatabaseName

select 'DBCC SHOWCONTIG (' + convert(varchar,o.id) + ',' +
convert(varchar,i.indid) + ') -- ' +
object_name(o.id) + -- table name
'.' + i.name -- index name
from sysobjects o join sysindexes i on (o.id = i.id)
where o.xtype = 'U' and i.rows > 0
order by object_name(o.id), i.indid

 

American Standard in SQL Server Training
 
SQLUSA.com Home Page