RESTORE Arguments (Transact-SQL)
This topic documents the arguments that are described in the Syntax sections of the RESTORE {DATABASE|LOG} statement and of the associated set of auxiliary statements: RESTORE FILELISTONLY, RESTORE HEADERONLY, RESTORE LABELONLY, RESTORE REWINDONLY, and RESTORE VERIFYONLY. Most of the arguments are supported by only a subset of these six statements. The support for each argument is indicated in the description of the argument.
WITH Options
Specifies the options to be used by a restore operation. For a summary of which statements use each option, see "Summary of Support for WITH Options," later in this topic.
Note |
|---|
WITH options are organized here in the same order as in the "Syntax" section in RESTORE {DATABASE|LOG}. |
<general_WITH_options> [ ,...n ]
The general WITH options are all supported in RESTORE DATABASE and RESTORE LOG statements. Some of these options are is also supported by one or more auxiliary statements, as noted below.
Restore Operation Options
These options affect the behavior of the restore operation.
Backup Set Options
These options operate on the backup set containing the backup to be restored.
Media Set Options
These options operate on the media set as a whole.
Data Transfer Options
The options enable you to optimize data transfer from the backup device.
Error Management Options
These options allow you to determine whether backup checksums are enabled for the restore operation and whether the operation will stop on encountering an error.
Monitoring Options
These options enable you to monitor the transfer of data transfer from the backup device.
Tape Options
These options are used only for TAPE devices. If a nontape device is being used, these options are ignored.
<replication_WITH_option>
This option is relevant only if the database was replicated when the backup was created.
<change_data_capture_WITH_option>
This option is relevant only if the database was enabled for change data capture when the backup was created.
<service_broker_WITH_options> [ ,...n ]
Turns Service Broker message delivery on or off, or sets a new Service Broker identifier. For more information about message delivery and Service Broker identifiers, see Managing Service Broker IdentitiesThis option is relevant only if Service Broker was enabled (activated) for the database when the backup was created.
<point_in_time_WITH_options>
Supported by: RESTORE {DATABASE|LOG} and only for the full or bulk-logged recovery models.
You can restore a database to a specific point in time or transaction, by specifying the target recovery point in a STOPAT, STOPATMARK, or STOPBEFOREMARK clause. A specified time or transaction is always restored from a log backup. In every RESTORE LOG statement of the restore sequence, you must specify your target time or transaction in an identical STOPAT, STOPATMARK, or STOPBEFOREMARK clause.
As a prerequisite to a point-in-time restore, you must first restore a full database backup whose end point is earlier than your target recovery point. To help you identify which database backup to restore, you can optionally specify your WITH STOPAT, STOPATMARK, or STOPBEFOREMARK clause in a RESTORE DATABASE statement to raise an error if a data backup is too recent for the specified target time. But the complete data backup is always restored, even if it contains the target time.
Note |
|---|
The RESTORE_DATABASE and RESTORE_LOG point-in-time WITH options are similar, but only RESTORE LOG supports the mark_name argument. |
For additional remarks, see the following topics:
Specifying a Backup Set
A backup set contains the backup from a single, successful backup operation. RESTORE, RESTORE FILELISTONLY, RESTORE HEADERONLY, and RESTORE VERIFYONLY statements operate on a single backup set within the media set on the specified backup device or devices. You should specify the backup you need from within the media set. You can obtain the backup_set_file_number of a backup set by using the RESTORE HEADERONLY statement.
The option for specifying the backup set to restore is:
FILE ={ backup_set_file_number | @backup_set_file_number }
Where backup_set_file_number indicates the position of the backup in the media set. A backup_set_file_number of 1 (FILE = 1) indicates the first backup set on the backup medium and a backup_set_file_number of 2 (FILE = 2) indicates the second backup set, and so on.
The behavior of this option varies depending on the statement, as described in the following table.
Statement | Behavior of backup-set FILE option |
|---|---|
RESTORE | The default backup set file number is 1. Only one backup-set FILE option is allowed in a RESTORE statement. It is important to specify backup sets in order. |
RESTORE FILELISTONLY | The default backup set file number is 1. |
RESTORE HEADERONLY | By default, all backup sets in the media set are processed. The RESTORE HEADERONLY results set returns information about each backup set, including its Position in the media set. To return information on a given backup set, use its position number as the backup_set_file_number value in the FILE option. NoteFor tape media, RESTORE HEADER only processes backup sets on the loaded tape. |
RESTORE VERIFYONLY | The default backup_set_file_number is 1. |
Note |
|---|
The FILE option for specifying a backup set is unrelated to the FILE option for specifying a database file, FILE = { logical_file_name_in_backup | @logical_file_name_in_backup_var }. |
Summary of Support for WITH Options
The following WITH options are supported by only the RESTORE statement: BLOCKSIZE, BUFFERCOUNT, MAXTRANSFERSIZE, PARTIAL, KEEP_REPLICATION, { RECOVERY | NORECOVERY | STANDBY }, REPLACE, RESTART, RESTRICTED_USER, and { STOPAT | STOPATMARK | STOPBEFOREMARK }
Note |
|---|
The PARTIAL option is supported only by RESTORE DATABASE. |
The following table lists the WITH options that are used by one or more statements and indicates which statements support each option. A check mark (√) indicates that an option is supported; a dash (—) indicates that an option is not supported.
WITH option | RESTORE | RESTORE FILELISTONLY | RESTORE HEADERONLY | RESTORE LABELONLY | RESTORE REWINDONLY | RESTORE VERIFYONLY |
|---|---|---|---|---|---|---|
{ CHECKSUM | NO_CHECKSUM } | √ | √ | √ | √ | — | √ |
{ CONTINUE_AFTER_ERROR | STOP_ON_ERROR } | √ | √ | √ | √ | — | √ |
FILE1 | √ | √ | √ | — | — | √ |
LOADHISTORY | — | — | — | — | — | √ |
MEDIANAME | √ | √ | √ | √ | — | √ |
MEDIAPASSWORD | √ | √ | √ | √ | — | √ |
MOVE | √ | — | — | — | — | √ |
PASSWORD | √ | √ | √ | — | — | √ |
{ REWIND | NOREWIND } | √ | Only REWIND | Only REWIND | Only REWIND | — | √ |
STATS | √ | — | — | — | — | √ |
{ UNLOAD | NOUNLOAD } | √ | √ | √ | √ | √ | √ |
1 FILE = backup_set_file_number, which is distinct from {FILE | FILEGROUP}.