SQL Server backup file bak, restore after backup error 3145, the database backup in the backup set is different from the existing ' xxx ' database.
The solution is as follows:
1, create a new database with the same name as the existing database.
If you don't know the database name, don't worry, execute the following statement to get the logical file name of the backup file:
Use Master; -- Use this statement to get the logical file name of the backup file RESTORE from DISK = N'E:\database\LocalDB\school.bak'-- The physical path of the backup file
The result of the above SQL command execution is to query out the backup file information, logical file name, etc.
--Logical file name to see the LogicalName field, generally there will be two files, such as:
--OLDDB--Main logical file name
--olddb_log--Log logical file name
OK, create a new database based on the logical file name (that is, the original database name).
2, run the following statement in the query window:
UseMaster;RESTORE DATABASETest--name of the database after the restore from DISK = 'E:\database\LocalDB\school.bak' --physical path of the backup file with Replace, MOVE N'Test' toN'E:\database\LocalDB\Test.mdf', MOVE N'Test_log' toN'E:\database\LocalDB\Test_log.ldf';--physical path of logical and log files after restore
From the statement point of view, and in the graphical interface operation is the same, but the result is the statement run successfully, the graphical interface how to pass.
The result of the RESTORE statement execution is as follows:
808 pages have been processed for database ' dataname ', file ' Panydb ' (located on file 1).
1 pages have been processed for database ' dataname ', file ' Panydb_log ' (located on file 1).
Converting database ' Dataname ' from version 539 to current version 611.
Database ' Dataname ' is being upgraded from version 539 to version 551.
Database ' Dataname ' is being upgraded from version 551 to version 552.
Database ' Dataname ' is being upgraded from version 552 to version 553.
Database ' Dataname ' is being upgraded from version 553 to version 554.
Database ' Dataname ' is being upgraded from version 554 to version 589.
Database ' Dataname ' is being upgraded from version 589 to version 590.
Database ' Dataname ' is being upgraded from version 590 to version 593.
Database ' Dataname ' is being upgraded from version 593 to version 597.
Database ' Dataname ' is being upgraded from version 597 to version 604.
Database ' Dataname ' is being upgraded from version 604 to version 605.
Database ' Dataname ' is being upgraded from version 605 to version 606.
Database ' Dataname ' is being upgraded from version 606 to version 607.
Database ' Dataname ' is being upgraded from version 607 to version 608.
Database ' Dataname ' is being upgraded from version 608 to version 609.
Database ' Dataname ' is being upgraded from version 609 to version 610.
Database ' Dataname ' is being upgraded from version 610 to version 611.
The RESTORE DATABASE successfully processed 809 pages and took 1.437 seconds (4.606 MB/s).
3, click on the restored database, right-click "Refresh", sure enough to restore success.
OK, you are done.
SQL Server Backup restore failed error error:3145 (database backup in Backup set differs from existing database) and workaround