• SQL-DBA-01 (4/16/2015)


    If you rebuild CLuster Index, by theory it also rebuilds all Non Cluster Indexes. Then why do we need to rebuild all Non Cluster Indexes? If only we can rebuild CLI, then it can do for the rest and we can save time?

    Wrong assumption on your part. From "Books Online"...

    REBUILD [ WITH (<rebuild_index_option> [ ,... n]) ]

    Specifies the index will be rebuilt using the same columns, index type, uniqueness attribute, and sort order. This clause is equivalent to DBCC DBREINDEX. REBUILD enables a disabled index. Rebuilding a clustered index does [font="Arial Black"]not [/font]rebuild associated nonclustered indexes unless the keyword ALL is specified. If index options are not specified, the existing index option values stored in sys.indexes are applied. For any index option whose value is not stored in sys.indexes, the default indicated in the argument definition of the option applies.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)