To remove a filegroup, all files associated with it need to be deleted.
To remove a file, all objects associated with it need to be removed.
If we have multiple files on a filegroup and we can use following command:
DBCC SHRINKFILE(file_name, EmptyFile)
This will move any objects in the file onto the other files in the filegroup. Then we can delete the file using following command:
ALTER DATABASE database_name
REMOVE FILE file_name
After this we can remove filegroup using following command:
ALTER DATABASE database_name
REMOVE FILEGROUP filegroup_name
But in my case, I have only one file in filegroup so how can I delete this file and then filegroup?
Comments
Post a Comment