Categories
Microsoft SQL Server

Script to rebuild or reorganize indexes in SQL databases

This link contains useful information and scripts to be used to rebuild or reorganize indexes in SQL databases.

Personally I found really useful the script at point D

https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-db-index-physical-stats-transact-sql?view=sql-server-2017

You can eventually comment adjust the following lines to prepare the scripts without run them

        --EXEC (@command);  
        --PRINT N'Executed: ' + @command;
        PRINT @command; 
        PRINT N'GO';

Did my post help you? Leave a reply.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.