Printed 2017/07/23 06:51PM

Rebuild indexes based on fragmentation - sp_RebuildIndex

By Basit Aalishan Masood-Al-Farooq, 2012/10/07

Reblogged from Basit's SQL Server Tips:

In my previous post here, I’ve discussed how we can detect fragmentation in SQL Server databases indexes using dynamic management view function sys.dm_db_index_physical_stats. In this post, I’m sharing my stored procedure which I’ve created a while ago to rebuild fragmented indexes based on the fragmentation level. This stored procedure is based on sys.dm_db_index_physical_stats and resides in master database. This procedure automatically rebuilds indexes if the fragmentation level is above 30% and reorganises indexes if fragmentation is less than 30%.

Read more… 1,544 more words

Bug fixed: it now rebuilds indexes, with space in their name.

Copyright © 2002-2017 Redgate. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.