--Create Test database
Create DATABASE Test
On primary
(
Name= ' Test_data.mdf ',
Filename= ' D:test_data.mdf '
)
Log on
(
Name= ' Test_data.ldf ',
Filename= ' D:test_data.ldf '
)
--Create a test table
CREATE TABLE Test.dbo.ta (ID int)
INSERT into Test.dbo.ta select ID from sysobjects
--Create a backup file
Backup database Test to disk= ' D:test.bak ' with format
--Create a NDF file
ALTER DATABASE Test
Add File
(
Name= ' file ',
Filename= ' D:test.ndf ',
SIZE = 1MB
)
--Shut down the MSSQL service, then delete the NDF file and then open the MSSQL service, the test database is suspect now!
--Recovery data suspect
--Back up the log files first
Backup log Test to disk= ' D:test_log.bak ' with format,no_truncate
--Recover corrupted files with file group backup files
Restore database Test from disk= ' D:test.bak ' with Norecovery
--Recovery log files
Restore Log Test from disk= ' D:test_log.bak ' with RECOVERY
--tips
If the NDF file has been established, then restore the log file with the following words
--Only the with Recovery-->with REPLACE
Restore Log Test from disk= ' D:test_log.bak ' with REPLACE