How to connect the SQLSERVER file group online after it is taken offline by mistake

Source: Internet
Author: User
Scenario: during the recovery process of the learning file group, the file group is taken OFFLINE through ALTERDATABASETESTMODIFYFILE (NAMESUBF, OFFLINE. At this time, we found that we forgot to back up before going offline. How can I restore the offline file group? The same command does not have the ONLINE option: ALTERDATABASETESTMODIFYFILE (NAME

Scenario: during the recovery process of the learning FILE group, the FILE group is OFFLINE through alter database test modify file (NAME = SUBF, OFFLINE. At this time, we found that we forgot to back up before going offline. How can I restore the offline file group? The same command does not have the ONLINE option: alter database test modify file (NAME

Scenario: when learning to restore a file group

ALTER DATABASE TEST MODIFY FILE(NAME = SUBF,OFFLINE)

Offline the file group. At this time, we found that we forgot to back up before going offline.

How can I restore the offline file group?

The same command does not have the ONLINE option:

ALTER DATABASE TEST MODIFY FILE(NAME = SUBF,ONLINE)

Message 155, Level 15, status 1, 1st rows
'Online' is not an identifiable CREATE/alter database option.

Modify the offline status of the database. After the database is online, the offline file group is still in the offline status.

ALTER DATABASE TEST SET OFFLINEALTER DATABASE TEST SET ONLINE

When the database is detached and attached, the offline file group is still offline.

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

In fact, you can restore the file (even if there is no backup ):

RESTORE DATABASE TEST FILE='SUBF' WITH RECOVERY

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

Add another file replacement algorithm provided by Hua Zi:

1. Separate the database (sp_detach_db 'xx ')

2. Move all files in the database

3. Create an empty library with the same name according to the original file

4. Change the empty database OFFLINE (alter database xx set offline)

5. Move the files removed from step 2 back and replace the files generated by the empty library created in step 3.

6. set the database online (alter database xx set online). If the database cannot be online, set it to the emergency status first.

The above method has passed the test.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.