Thursday, May 26, 2016

Restore read-only filegroup

If you are missing a file in a read-only filegroup, you can offline that file (which will of course offline the whole filegroup), and continue working with other filegroups. Any queries over global indexes will work fine.

  • ALTER DATABASE dbdb MODIFY FILE (NAME = 'filename_april2', OFFLINE)
If, at this point, you managed to restore the corrupted file (let's call it filename_april2), you can recover the whole filegroup and continue working without any impact on the rest of the database. Neat.
  • RESTORE DATABASE dbdb FILEGROUP='april_fg' WITH RECOVERY

Note: Each filegroup has a primary and secondary files. This restore applies to either primary or secondary file, as long as the filegroup is read-only.

No comments: