Rebuild All Indexes of Database

When DML(Insert, Update,Delete) operations are performed on a table then table fragmentation occurs, and this fragmentation degrades the performance of database. So it is necessary to rebuild all indexes to improve the performances of indexes. We will use the "DBCC DBRINDEX" to drop and rebuild all the indexes.
 
Query:

  1. EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"  
  2.   
  3. GO  
  4.   
  5. EXEC sp_updatestats  
  6.   
  7. GO  

Output: