Online file Restore: If the larger MSSQL database is damaged only by concentrating on one of the files or filegroups, using the online file restore technology,
Just rebuilding a broken data file or filegroup can save a lot of time.
The following is a test script (assuming a corrupted file is Trn01):
--FirstRestore corrupted file Trn01 (before you perform this step, you must obtain exclusive access to the database):RESTORE DATABASE [AdventureWorks] FILE=N'Trn01' from DISK=N'D:\BACKUP_TEST\AD_FULL. BAK' withNorecovery,stats=Ten--If it is not an Enterprise Edition, error message 3159 prompts you to use BACKUP LOG with NORECOVERY to back up the tail log, which means that you can only restore files offline.
--BACKUP LOG [AdventureWorks] to DISK =n ' D:\BACKUP_TEST\Log_BACK_TAIL. TRN ' with norecovery,compression,stats=10 --in other words, if it is an Enterprise Edition, you can release exclusive access at this point when execution is complete. (If you change to Single_user mode, you can now change to multi_user release access.)--However, the filegroup trn that the Trn01 belongs to cannot be accessed, and the contents of the database outside the TRN filegroup can be accessed. --If you try to access a table in Trn01, the following error message appears:--msg 8653, Level 16, State 1, line 2nd--The query processor cannot generate a schedule for a table or view "* * *" because the table resides in a filegroup that is not in the online state. --backup file offline point in time log:BACKUP LOG [AdventureWorks] to DISK =N'D:\BACKUP_TEST\Log_BACK_TAIL. TRN' withCopy_only,compression,stats=Ten--Restore the log in turn:RESTORE LOG [AdventureWorks] from DISK=N'D:\BACKUP_TEST\LOG_BACK_1.TRN' withNorecovery,stats=TenRESTORE LOG [AdventureWorks] from DISK=N'D:\BACKUP_TEST\LOG_BACK_2.TRN' withNorecovery,stats=Ten--to restore a file offline point in time log:RESTORE LOG [AdventureWorks] from DISK=N'D:\BACKUP_TEST\Log_BACK_TAIL. TRN' withRecovery,stats=Ten