views:

254

answers:

2

Can anyone provide the script for rebuilding and reindexing the fragmented index when 'avg_fragmentation_in_percent' exceeds certain limits without using a cursor?

+2  A: 

Try this:

ALTER INDEX __NAME_OF_INDEX__ ON __NAME_OF_TABLE__ REBUILD
ALTER INDEX __NAME_OF_INDEX__ ON __NAME_OF_TABLE__ REORGANIZE
KM
+1  A: 

I have found the following script is very good at maintaining indexes, you can have this scheduled to run nightly or whatever other timeframe you wish.

http://sqlfool.com/2009/06/index-defrag-script-v30/

Lima