Pokazywanie postów oznaczonych etykietą T-SQL. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą T-SQL. Pokaż wszystkie posty

środa, 10 lutego 2010

Restoring Database in SQL Server 2005

This is quick tip explaining how to restore database in SQL Server 2005. The new database had different schema than the one I wanted to restore data to.
This is the sql Generated by Sql management studio:
RESTORE DATABASE [DatabaseName] 
FROM  DISK = N'C:\temp\db\DBBackup.bak' 
WITH  FILE = 1,  NOUNLOAD,  STATS = 10
GO

Unfortunately it running it couses an error: Error 3154: The backup set holds a backup of a database other than the existing database.
All you need to do is to add parameter REPLACE. this is how new query looks like:
RESTORE DATABASE [DatabaseName] 
FROM  DISK = N'C:\temp\db\DBBackup.bak' 
WITH  REPLACE, FILE = 1,  NOUNLOAD,  STATS = 10
GO