INF: Using the WITH MOVE Option with the RESTORE Statement

ID: Q221465


The information in this article applies to:


SUMMARY

SQL Server 6.5 used the DUMP and LOAD statements to make a backup copy of a database and subsequently reload it. In SQL Server 7.0, this terminology has changed to BACKUP and RESTORE.

The information in this article is meant to explain the proper usage of the WITH MOVE option with the RESTORE Transact-SQL statement.


MORE INFORMATION

A RESTORE statement always produces a database that is identical to the one that was backed up. The database produced by the RESTORE will have the same number of files, and the files will be of the same size, as determined by the BACKUP. The backup file contains information on the name, number, size, and location of all files for the database at the time the backup was created. When you RESTORE a backup and allow SQL Server to re-create the database for you, the following occurs:

Therefore, if you want to change the location of the files when restoring the database, you have the following options: Note that SQL Server may require you to use the MOVE clause if restoring a file would overwrite an existing file that is in use by another database. You will receive the following messages in this case:
Server: Msg 3156, Level 16, State 2, Line 1
The file 'D:\MSSQL7\data\Filename_Data.MDF' cannot be used by RESTORE.
Consider using the WITH MOVE option to identify a valid location for the file.

Server: Msg 3013, Level 16, State 1, Line 1
Backup or restore operation terminating abnormally.

REFERENCES

SQL Server 7.0 Books Online; RESTORE (T-SQL)

Additional query words: tsql transql transsql err msg error message back up backed dump dumped


Keywords          : SSrvTran_SQL 
Version           : winnt:7.0
Platform          : winnt 
Issue type        : kbinfo 

Last Reviewed: May 4, 1999