Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin.
Search for scripts directly from SSMS, and instantly access any saved scripts in your
SSC briefcase from the favorites tab.
Download now (direct download link)
Thank this author by sharing:
By Hakim Ali,
I recently had the need to look up all fragmented indexes on a specific database, to determine if they were the reason for less than optimal performance. I wrote the following script, which allows you to pick a specific database to check for fragmented indexes, and decide to just view them or reorganize/rebuild them, and also the fragmentation threshold percentage at which to run these operations. Then I thought it might be useful to others too, so here it is.
Rebuild or Reorganize Indexes
Index Rebuild VS Reorganize What is the difference between Index rebuild(alter index .. Rebuild) and...
Using sys.dm_db_index_physical_stats in a script to rebuild or reorganize indexes
Index Rebuilds Still Leave Fragmentation
Rebuild,Reorganize index job failed