2

Below is the query that I am using to restore my database.

However, whenever I run it, i always get this error message:

Msg 4038, Level 16, State 1, Line 1
Cannot find file ID 1 on device 'D:\DB_Backup\MMS.BAK'.

Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

This is my query:

RESTORE DATABASE METERIAL_MANAGEMENT_2 
FROM DISK = 'D:\DB_Backup\MMS.BAK'
WITH 
 MOVE 'METERIAL_MANAGEMENT' TO 'D:\DATA\METERIAL_MANAGEMENT_2.mdf',
 MOVE 'METERIAL_MANAGEMENT_log' TO 'D:\DATA\METERIAL_MANAGEMENT_2_Log.ldf'
asked Jan 21, 2017 at 3:52
2
  • 1
    Your code uses RESTORE DATABASE, which is used to restore a database from a file, not back up a database to a file. Use BACKUP DATABASE to create the backup file. Commented Jan 21, 2017 at 5:00
  • 2
    Run RESTORE FILELISTONLY FROM DISK = 'D:\DB_BACKUP\MMS.BAK'; to see what backups are listed in the file. Perhaps the file doesn't contain any valid database backups, or is corrupted in some way. Commented Jan 21, 2017 at 16:30

1 Answer 1

1

Your code is for Restoring a database not to create a backup file. you have to use the following code:

BACKUP DATABASE METERIAL_MANAGEMENT_2 
TO DISK = 'D:\DB_Backup\MMS.BAK'

Read more about Creating a full backup using T-SQL in the following TechNet article

answered Jan 21, 2017 at 6:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.