Partition index

  • Hi All,

    Can anyone help on getting a scripts to rebuild index for all db's except the Partitioned table indexes.

    Thanks in Advance,

    Gagan

  • Hi,

    Take a look at the following article[/url], it contains a reference to one of the best index rebuild scripts there is. When the stored procedure encounters a partitioned index, it performs a specific action.

    Index Optimisation Script Link

    [/url]

    See procedure snippet below that identifies the partitioned indexes.

    /* Determine if the index is partitioned */

    SELECT @partitionSQL = 'Select @partitionCount_OUT = Count(*)

    From ' + @databaseName + '.sys.partitions

    Where object_id = ' + CAST(@objectID AS VARCHAR(10)) + '

    And index_id = ' + CAST(@indexID AS VARCHAR(10)) + ';'

    , @partitionSQL_Param = '@partitionCount_OUT int OutPut';

    I'm certain you could easily modify the stored procedure and/or code to suit your needs.

    Cheers,

Viewing 2 posts - 1 through 1 (of 1 total)

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