The Attached SQL Query can be safely used for rebuilding or reorganizing all indexes in a particular database based on the fragmentation level.
Note: The script is currently set to perform offline index rebuild since online index rebuild is supported only in Enterprise edition SQL Server. Inorder to change it into online mode, add
, ONLINE = ON statement along with
<span style="padding: 2px; border: 1px solid #00ff00;">FILLFACTOR = 80, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON</span>
in line 100 in the attached script.
3203_AutoIndexRebuild2005andAbove (Click to download the script)