This tutorial will walk you through on how to automatically build a SQL: query that will either reorganize an Index or Rebuild an Index based on thresholds you determine in the script. You will build a global temp table then insert some data from Indexes and then based on the average fragmentation, you will rebuild/reorganize the indexes in your Database. This script is useful when introducing it to a SSIS job package.
Github Index Folder:
https://github.com/ProfessorPitch/ProfessorPitch/tree/master/SQL/Indexes