offline filegroup that having multiple files

sakuraime 2,326 Reputation points
2020-10-28T18:01:20.573+00:00

How to offline the whole filegroups that has multiple files ?

ALTER DATABASE dbname MODIFY FILE (NAME = 'filename', OFFLINE) << this can only offline a single file

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,677 questions
{count} votes

Accepted answer
  1. Cris Zhan-MSFT 6,626 Reputation points
    2020-10-29T09:10:55.243+00:00

    Hi @sakuraime ,

    Please read the MS doc :ALTER DATABASE (Transact-SQL) File and Filegroup Options. You can MODIFY FILE to OFFLINE, but there is no command to make a filegroup offline.

    OFFLINE Sets the file offline and makes all objects in the filegroup inaccessible.


2 additional answers

Sort by: Most helpful
  1. Erland Sommarskog 110.4K Reputation points MVP
    2020-10-28T22:31:45.717+00:00

    Yes, but Books Online says: Sets the file offline and makes all objects in the filegroup inaccessible.

    Furthermore: Use this option only when the file is corrupted and can be restored. A file set to OFFLINE can only be set online by restoring the file from backup.

    1 person found this answer helpful.
    0 comments No comments

  2. tibor_karaszi@hotmail.com 4,311 Reputation points
    2020-10-29T13:36:05.16+00:00

    Just a note that you can set the filegroup Read Only. You don't tell what your scenario is, so it is difficult to suggest what might be useful for you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.