We have a SQL Server database with two filegroups; PRIMARY
and SECONDARY
, with a single file in each file group.
All the clustered indexes are stored in the secondary filegroup. How can we remove the SECONDARY
filegroup?
filegroupssql server
We have a SQL Server database with two filegroups; PRIMARY
and SECONDARY
, with a single file in each file group.
All the clustered indexes are stored in the secondary filegroup. How can we remove the SECONDARY
filegroup?
Best Answer
The clustered index structure is the table in SQL Server.
In order to remove a filegroup, you first need to remove all data from the filegroup. There are several ways of doing that, including using the GUI, like this:
Be aware, this method will result in SSMS generating code that actually drops-and-recreates the table.
An alternate method of doing that would be to rebuild the indexes for the table, specifying the target filegroup in the rebuild command. I've written a blog-post showing the code I use to accomplish that over at SQLServerScience.com