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:
- EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"
-
- GO
-
- EXEC sp_updatestats
-
- GO
Output: