Dustin Davis
Dustin Davis

Reputation: 14585

SQL move all indexes for a table to a file group

Is there a TSQL way to move all indexes for a table to a filegroup without doing it one by one? It's looking like a dynamic SQL type of scenario.

Upvotes: 1

Views: 185

Answers (1)

Dustin Davis
Dustin Davis

Reputation: 14585

You can use Object Explorer Details (Management Studio), browse to the table then to it's indexes folder. Highlight all then script -> Create to -> new query window

It will generate all of your create scripts. Change the DROP_EXISTING = OFF to DROP_EXISTING = ON and the change [PRIMARY] to what ever your new file group name is.

This requires a few manual steps but gives good control especially if you only want select indexes (not all of them).

Upvotes: 1

Related Questions