-- 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 an NDF File
Alter database Test
Add file
(
Name = 'file ',
Filename = 'd: test. ndf ',
SIZE = 1 MB
)
-- Disable the MSSQL service, delete the NDF file, and enable the MSSQL service. The Test database is suspected!
-- Restore Data suspect
-- First back up the log file
Backup log Test to disk = 'd: Test_log.bak 'with format, no_truncate
-- Use the backup file of the file group to restore the damaged file
Restore database Test from disk = 'd: Test. bak 'with Norecovery
-- Restore log files
Restore Log Test from disk = 'd: Test_log.bak 'with RECOVERY
-- TipS
-- If an ndf file has been created, use the following statement to restore the log file:
-- Only with RECOVERY --> WITH REPLACE
Restore Log Test from disk = 'd: Test_log.bak 'WITH REPLACE