I have two databases db1 and db2 on the same SQL Server I took the backup of db1 using the query BACKUP DATABASE [db1] TO DISK = 'C:\\db\\db1.bak'
Now I tried to restore the backup in db2 using the query
RESTORE DATABASE db2 FROM DISK = 'C:\\db\\db1.bak' WITH MOVE 'db2' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\db2.mdf', MOVE 'db2_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\db2_log.ldf'
but it resulted in error How can I restore a backup of a db into another db in the same server
sorry webfred in the above I had used WITH MOVE not WITH REPLACE and the error I am getting is
The backup set holds a backup of a database other than the existing 'db2' database. Msg 3013, Level 16, State 1, Line 2 RESTORE DATABASE is terminating abnormally.
========================================== Cursors are useful if you don't know sql. SSIS can be used in a similar way. Beer is not cold and it isn't fizzy.
Thankyou for all valuable replays finally it worked with the following query I missed WITH MOVE REPLACE
RESTORE DATABASE db3 FROM DISK = 'C:\\db\\db1.bak' WITH MOVE 'db1' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\db3.mdf', MOVE 'db1_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\db3_log.ldf',REPLACE