RESTORE Statements - REWINDONLY (Transact-SQL)

Applies to: SQL Server

Rewinds and closes specified tape devices that were left open by BACKUP or RESTORE statements executed with the NOREWIND option. This command is supported only for tape devices.

Transact-SQL syntax conventions

Syntax

  
RESTORE REWINDONLY   
FROM <backup_device> [ ,...n ]  
[ WITH {UNLOAD | NOUNLOAD}]  
}   
[;]  
  
<backup_device> ::=  
{   
   { logical_backup_device_name |  
      @logical_backup_device_name_var }  
   | TAPE = { 'physical_backup_device_name' |  
       @physical_backup_device_name_var }   
}   

Note

To view Transact-SQL syntax for SQL Server 2014 (12.x) and earlier versions, see Previous versions documentation.

Arguments

<backup_device> ::=

Specifies the logical or physical backup devices to use for the restore operation.

{ logical_backup_device_name | @logical_backup_device_name_var }
Is the logical name, which must follow the rules for identifiers, of the backup devices created by sp_addumpdevice from which the database is restored. If supplied as a variable (@logical_backup_device_name_var), the backup device name can be specified either as a string constant (@logical_backup_device_name_var = logical_backup_device_name) or as a variable of character string data type, except for the ntext or text data types.

{DISK | TAPE } = { 'physical_backup_device_name' | @physical_backup_device_name_var }
Allows backups to be restored from the named disk or tape device. The device types of disk and tape should be specified with the actual name (for example, complete path and file name) of the device: DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\Mybackup.bak' or TAPE = '\\.\TAPE0'. If specified as a variable (@physical_backup_device_name_var), the device name can be specified either as a string constant (@physical_backup_device_name_var = 'physical_backup_device_name') or as a variable of character string data type, except for the ntext or text data types.

If using a network server with a UNC name (which must contain machine name), specify a device type of disk. For more information about using UNC names, see Backup Devices (SQL Server).

The account under which you are running Microsoft SQL Server must have READ access to the remote computer or network server in order to perform a RESTORE operation.

n
Is a placeholder that indicates multiple backup devices and logical backup devices can be specified. The maximum number of backup devices or logical backup devices is 64.

Whether a restore sequence requires as many backup devices as were used to create the media set to which the backups belong, depends on whether the restore is offline or online. Offline restore allows a backup to be restored using fewer devices than were used to create the backup. Online restore requires all the backup devices of the backup. An attempt to restore with fewer devices fails.

For more information, see Backup Devices (SQL Server).

Note

When restoring a backup from a mirrored media set, you can specify only a single mirror for each media family. In the presence of errors, however, having the other mirror(s) enables some restore problems to be resolved quickly. You can substitute a damaged media volume with the corresponding volume from another mirror. Note that for offline restores you can restore from fewer devices than media families, but each family is processed only once.

WITH Options

UNLOAD
Specifies that the tape is automatically rewound and unloaded when the RESTORE is finished. UNLOAD is set by default when a new user session is started. It remains set until NOUNLOAD is specified. This option is used only for tape devices. If a non-tape device is being used for RESTORE, this option is ignored.

NOUNLOAD
Specifies that the tape is not unloaded automatically from the tape drive after a RESTORE. NOUNLOAD remains set until UNLOAD is specified.

General Remarks

RESTORE REWINDONLY is an alternative to RESTORE LABELONLY FROM TAPE = <name> WITH REWIND. You can get a list of opened tape drives from the sys.dm_io_backup_tapes dynamic management view.

Security

Permissions

Any user may use RESTORE REWINDONLY.

See Also

BACKUP (Transact-SQL)
Media Sets, Media Families, and Backup Sets (SQL Server)
RESTORE (Transact-SQL)
Backup History and Header Information (SQL Server)