rebuild/reorg specific tabels - filegroups

  • Hey everyone.. hope u can help me out here.

    Could u help me with a t-sql for index maintenance.

    -----------------------------------------------------------

    I have a primary filegroup, and a deleted filegroup.

    primary has 700 tables. I would like to index maintenance the 600 of them (because the last 100 are very large, and i would like to run this on another time)

    deleted has 6 very large tables.

    -----------------------------------------------------------

    I would like to run a script, that runs through 600 out of 700 tabels in the primary filegroup, and reorganizes/rebuilds indexes.

    I've seen a couple of other index maintenance jobs out there,, but the issue is they run through all the tables.

    I would like to have a job for my primary,, and then my secondary filegroup.

    Right now im doing this;

    ALTER INDEX ALL ONDBO.Table1REBUILD WITH (FILLFACTOR = 80);

    ALTER INDEX ALL ONDBO.Table2REBUILD WITH (FILLFACTOR = 80);

    ALTER INDEX ALL ONDBO.Table3REBUILD WITH (FILLFACTOR = 80);

    or

    ALTER INDEX ALL ONDBO.Table3REORGANIZE;

    good things with this:

    I can choose to run a maintenance on my smallest tables/indexes, and leave out large tables (they will run on another time).

    issues with this.

    1=I cant see the progress. 2= I am not checking for fragmentation level, so it will rebuilding/reorg each time.

    Im sure there is a smarter way to do this. I want to run through tables 1,2,3,4,5 but not 6,7,8 in primary filegroup.

    I want to find out whether the chosen tables needs a reorganize or rebuild and do so.

    and then the same job for my deleted filegroup (which i will run on another time)

    Thanks in advance

  • thanks steve',,

    im actually just having a look at it.. thanks =)

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

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