Rebuild All index In SQL Server

Index Maintenance is one of the major task for a DBA. If rate of Index fragmentation increased then index de-fragmentation is become required.  So we can use index rebuild option to rebuild all the indexes. Use Index Rebuild option when rate of index fragmentation is greater then 40%.
 
Syntax:
 
Alter Index All On Table_Name Rebuild.
 
Example:
 
ALTER INDEX ALL ON geographicals REBUILD
GO
 
 
 
Rebuild Index for All tables in database:
 
Exec sp_msforeachtable 'ALTER INDEX ALL ON ? REBUILD'
GO
 
 
Ebook Download
View all
Learn
View all