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
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
In past, many times I have written on Fragmentation of Indexes and how to Defrag them....