how to modify index maintenance script

Vijay Kumar 2,061 Reputation points
2025-10-14T23:33:02.8266667+00:00

Hi Team,

How to modify T-sql indexmaintenance script only do Index Reorganize

SQL Server | SQL Server Transact-SQL
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Damien Pham (WICLOUD CORPORATION) 1,315 Reputation points Microsoft External Staff Moderator
    2025-10-15T09:51:30.7866667+00:00

    Hello @Vijay Kumar ,

    To modify your index maintenance script to only perform REORGANIZE by removing or replacing any REBUILD logic. If your script uses conditions based on fragmentation, make both medium and high fragmentation levels use REORGANIZE.

    For example:

    ALTER INDEX [IndexName] ON [Schema].[TableName] REORGANIZE;
    
    
    

    If you are using Ola Hallengren’s maintenance script, you can set both parameters to reorganize only:

    EXEC dbo.IndexOptimize
        @Databases = 'YourDatabase',
        @FragmentationMedium = 'INDEX_REORGANIZE',
        @FragmentationHigh = 'INDEX_REORGANIZE';
    

    This will ensure all indexes are reorganized and never rebuilt.

    For more information, you can refer to this article here: https://free.blessedness.top/en-us/sql/relational-databases/indexes/reorganize-and-rebuild-indexes?view=sql-server-ver17

    If you need more precise assistance, feel free to share more context of your script so I can assist you better.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.