A blog about SQL Server, SSIS, C# and whatever else I happen to be dealing with in my professional life.

Find ramblings

Thursday, March 27, 2014

Biml - RebuildIndex Task

Biml - RebuildIndex Task

The maintenance task, Rebuild Index Task, described with Biml. By now you know the drill, it requires an ADO.NET Connection Manager to work.

<Biml xmlns="http://schemas.varigence.com/biml.xsd">
    <Packages>
        <Package 
            ConstraintMode="Linear" 
            Name="Task_RebuildIndex">
            <Tasks>
                <RebuildIndex 
                    ConnectionName="CM_ADO_DB" 
                    DatabaseSelectionMode="All" 
                    ObjectSelectionMode="Tables" 
                    Name="RI All Tables">
                </RebuildIndex>
                
                <!-- 
                    Rebuild the index on a specific view
                -->
                <RebuildIndex
                    ConnectionName="CM_ADO_DB"
                    DatabaseSelectionMode="Specific"
                    ObjectSelectionMode="Views"
                    Name="RI Specific View"
                    ReindexPercentage="50"
                    ReindexWithOriginalAmount="false"
                    SortInTempDB="false"
                    SkipUnsupported="true"
                    KeepOnline="true">
                    <Databases>
                        <Database>AdventureWorks2012</Database>
                    </Databases>
                    <Objects>
                        <Object>Production.vProductAndDescription</Object>
                    </Objects>
                </RebuildIndex>
            </Tasks>
        </Package>
    </Packages>
</Biml>

Result

The above Biml describes a package that creates two Rebuild Index Tasks. The first rebuilds on all the tables while the second targets a specific indexed view.

RI All Tables

Here we reindex all the tables in all the databases.

RI Specific View

This snippet of Biml describes reindexing a specific view, Production.vProductAndDescription in the AdventureWorks2012 database.

Specify Database

Specify the database(s) we should use. Normally, I'd have trimmed out the empty space at the top of the window there but I left it as is to point out the wasted real estate. It's like there's a missing title block.

Specify Object

Here we're selecting the one object we're interested in re-indexing.

No comments: