Moving Index Filegroup

  • Does anybody know of an easy way (using TSQL) to move an index from one filegroup to another.

    I know it's easy in Enterprise Manager, but I have 100's of indexes to move, and need to script the change.

    I could also script it using sysindexes, syscolumns etc, but was wondering if there's an easier way.

    Edited by - ianscarlett on 11/05/2003 03:36:02 AM

  • It'd be fairly easy to write a script to DROP them all.

    Then maybe use EM scripting: select all tables; uncheck everything in Formatting; choose only Script Indexes in Options. Then, before running the generated script, change all "ON [PRIMARY]" to "ON [IansNewFilegroup]"

    Cheers,

    - Mark


    Cheers,
    - Mark

  • Thanks Mark,

    I'll do that, as it's easy to add the DROP_EXISTING clause to the script it produces.

  • quote:


    I'll do that, as it's easy to add the DROP_EXISTING clause to the script it produces.


    Now, why didn't I think of that? I was thinking at the time... wouldn't an ALTER INDEX statement be handy.

    Cheers,

    - Mark


    Cheers,
    - Mark

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

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