views:

279

answers:

1

I have a database backup for which SQL Server Management Studio says that it has three files in it: an .mdf file, an .ndf file and one .ldf file. This secondary data file (the .ndf one) was created for no obvious reason, so I want to remove it altogether (without losing data, of course), preferably during while the database is being restored from the backup.

Is this at all doable?

+2  A: 

Ok, found a solution.

  • Back up the database
  • Execute

    use database_name dbcc shrinkfile('ndf_file_name', EMPTYFILE)

  • Execute

    alter database database_name remove file 'logical_ndf_file_name'

Anton Gogolev
was there data in your file ? and if so how long did it take , and was the DB live ?
Hassan Syed
@Hassan NDF was about 8 Gb, while MDF was around 60 Gb. It took about 20 minutes all in all. Not sure about what you mean by "live". I didn't take it offline, but no queries were run against it either.
Anton Gogolev
@Anton interesting information. By Live I meant production use or customer facing.
Hassan Syed
@Hassan I doubt that it was available for production use.
Anton Gogolev

related questions