• Hi Raj,

    Nice article. In the attachment there is a script that moves multiple tables in different databases at once. The original description of the script is here:

    http://tsql.ca/Resources/Articles/MoveTablesbetweenFilegroups/tabid/610/Default.aspx

    Unfortunately at the publishing time the some characters disappeared from the script, so I attached it here.

    The idea was the same as yours - recreate the clustered index on another filegroup.

    So, in my script (new) filegroups are assumed to be in place. All you need is to create a list of database/table/filegroup elements. Each table will be checked if it is in a proper filegroup, if not - it's moved to the proper one.

    There are few more moments one should consider, especially if you plan to free and remove the original filegroup:

    1. BLOB data is not moved this way, it resides in the original location. That means for the tables with BLOBs one has to create new table in the another filegroup(possibly specifying different filegroup for the BLOB data); copy the data over; drop original table and rename the new table.

    2. Statistics is not moved this way. It should be detected by the table name and then dropped. When recreated - it will be placed in the same [new] filegroup as the table.

    Such scenarios I handle in separate scripts delivered along with the attached one through my incremental build mechanism described here:

    http://www.simple-talk.com/sql/database-administration/deploying-database-developments/