Saturday, January 19, 2013

SQL-SERVER Backup RESTORE error

when trying to restore the database i get something like this:


Restore failed for Server '\SQLEXPRESS'. (Microsoft.SqlServer.SmoExtended)

System.Data.SqlClient.SqlError: The backup set holds a backup of a database other than the existing ' ' database. (Microsoft.SqlServer.Smo)

The solution for this is simple: you need to choose "WITH REPLACE" option when restoring.

Check this option ‘Overwrite the existing database (WITH REPLACE)’.
"OK"


You might also got this error

Restore failed for Server ' \SQLEXPRESS'. (Microsoft.SqlServer.SmoExtended)

System.Data.SqlClient.SqlError: The file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\scott.mdf' cannot be overwritten. It is being used by database ' '. (Microsoft.SqlServer.Smo)

to restore the database use WITH MOVE option

RESTORE DATABASE [new_dbname]
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\old_dbname.bak' 
WITH FILE = 1, MOVE N'old_dbname'
TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\new_dbname.mdf',
MOVE N'old_dbname_log'
TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\new_dbname.ldf',
NOUNLOAD, REPLACE, STATS = 10





No comments:

Post a Comment

web stats