Restoring a database in SQL 2005

If you are using SQL Management Studio Express to restore a database backup to SQL 2005, and the backup came from a different server, or a different database, then you may encounter the following error:






The solution is to go the Options tab, and select the option to overwrite the existing database:




Note that the equivalent SQL is to simply add the REPLACE option to the RESTORE command:

RESTORE DATABASE [SR_UKSEC_DB1] FROM DISK = N'C:\SeanRyan\databases\MsSql\Backups\DbCleanBackups\SR_UKSEC_DB1.bak' WITH FILE = 1, NORECOVERY, NOUNLOAD, REPLACE, STATS = 10
GO

Comments