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'

migrated from stackoverflow.com Jan 21 '17 at 10:40

This question came from our site for professional and enthusiast programmers.

  • 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. – drf Jan 21 '17 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. – Max Vernon Jan 21 '17 at 16:30
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy