Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to delete a filegroup which has only one file?

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