Restoring a backup using SQL
June 24, 2009
This is something I have to do about two times a year and always forget. It’s useful if you are restoring a backup from a development or live server, and the data files are pointing in different places.
RESTORE DATABASE SOME_DB
FROM DISK = 'C:\backups\some_db.bak'
WITH REPLACE,
MOVE 'some_db' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Data\dsome_db.mdf',
MOVE 'some_db_log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Data\some_db_log.ldf'