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'
1 Answer 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
RESTORE DATABASE
, which is used to restore a database from a file, not back up a database to a file. UseBACKUP DATABASE
to create the backup file.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.