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.
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).
精彩评论