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.