Can I detete a Datafile or FileGroup

  • Hi

    In a server we had File Growth,And then We had to Add New Hard Drive And New File On It.

    And Now We have New server with a Huge Hard Drive.

    But all files remaind.

    Can I Reduce This files to One data file or not ?

    Thank you

  • You can empty a file and the delete it by using DBCC SHRINKFILE:

    DBCC SHRINKFILE (N'MyDatafile' , EMPTYFILE)

    -- Gianluca Sartori

  • More exactly, you first need to empty the file with the command spaghettidba gave you, and then you will be able to remove this file with the following instruction :

    ALTER DATABASE myDB

    REMOVE FILE logicalFileName

    A non-empty file cannot be removed. You can check the amount of space occupied in the file using the FILEPROPERTYEX function and its SpaceUsed parameter, passing the name column of the sys.database_files as the first parameter.

    @++ 😉

  • A filegroup can only be removed once it has no files remaining.

    Did you create a new filegroup or did you just add files to the existing filegroup

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply