dynamic script for reindexing fragmented indexes

  • I have a script where it finds all the indexes where the fragmentation percent is above 30. I would like to create a dynamic query to rebuild those indexes where the frag > 30

    any pointers would be gretly appreciated. Thanks

  • Have you checked out Ola Hallengren's maintenance solution? This covers defragmenting indexes like what you're after and is very configurable.

    Main Site:

    http://ola.hallengren.com

    Index Maintenance Page:

    http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html

  • Ola Hallengren has already done the work for you. Check out his scripts[/url] for performing index maintenance and also backups and restores. These scripts are highly regarded in the SQL Server community.



    Microsoft Certified Master - SQL Server 2008
    Follow me on twitter: @keith_tate

    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Use Ola's scripts. No point in redoing all the work he's done.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply