ערוך

שתף באמצעות


RESTORE Statements - LABELONLY (Transact-SQL)

Applies to: SQL Server Azure SQL Managed Instance

Returns a result set containing information about the backup media identified by the given backup device.

Note

For the descriptions of the arguments, see RESTORE Arguments (Transact-SQL).

Transact-SQL syntax conventions

Syntax

  
RESTORE LABELONLY   
FROM <backup_device>   
[ WITH   
 {  
--Media Set Options  
   MEDIANAME = { media_name | @media_name_variable }   
 | MEDIAPASSWORD = { mediapassword | @mediapassword_variable }  
  
--Error Management Options  
 | { CHECKSUM | NO_CHECKSUM }   
 | { STOP_ON_ERROR | CONTINUE_AFTER_ERROR }  
  
--Tape Options  
 | { REWIND | NOREWIND }   
 | { UNLOAD | NOUNLOAD }    
 } [ ,...n ]  
]  
[;]  
  
<backup_device> ::=  
{   
   { logical_backup_device_name |  
      @logical_backup_device_name_var }  
   | { DISK | TAPE | URL } = { 'physical_backup_device_name' |  
       @physical_backup_device_name_var }   
}  
  

Note

URL is the format used to specify the location and the file name for Microsoft Azure Blob Storage and is supported starting with SQL Server 2012 (11.x) SP1 CU2. Although Microsoft Azure storage is a service, the implementation is similar to disk and tape to allow for a consistent and seamless restore experience for all the three devices.

Arguments

For descriptions of the RESTORE LABELONLY arguments, see RESTORE Arguments (Transact-SQL).

Result Sets

The result set from RESTORE LABELONLY consists of a single row with this information.

Column name Data type Description
MediaName nvarchar(128) Name of the media.
MediaSetId uniqueidentifier Unique identification number of the media set.
FamilyCount int Number of media families in the media set.
FamilySequenceNumber int Sequence number of this family.
MediaFamilyId uniqueidentifier Unique identification number for the media family.
MediaSequenceNumber int Sequence number of this media in the media family.
MediaLabelPresent tinyint Whether the media description contains:

1 = Microsoft Tape Format media label

0 = Media description
MediaDescription nvarchar(255) Media description, in free-form text, or the Tape Format media label.
SoftwareName nvarchar(128) Name of the backup software that wrote the label.
SoftwareVendorId int Unique vendor identification number of the software vendor that wrote the backup.
MediaDate datetime Date and time the label was written.
Mirror_Count int Number of mirrors in the set (1-4).

Note: The labels written for different mirrors in a set are identical.
IsCompressed bit Whether the backup is compressed:

0 = not compressed

1 =compressed

Note

If passwords are defined for the media set, RESTORE LABELONLY returns information only if the correct media password is specified in the MEDIAPASSWORD option of the command.

General Remarks

Executing RESTORE LABELONLY is a quick way to find out what the backup media contains. Because RESTORE LABELONLY reads only the media header, this statement finishes quickly even when using high-capacity tape devices.

Security

A backup operation may optionally specify passwords for a media set. When a password has been defined on a media set, you must specify the correct password in the RESTORE statement. The password prevents unauthorized restore operations and unauthorized appends of backup sets to media using Microsoft SQL Server tools. However, a password does not prevent overwrite of media using the BACKUP statement's FORMAT option.

Important

The protection provided by this password is weak. It is intended to prevent an incorrect restore using SQL Server tools by authorized or unauthorized users. It does not prevent the reading of the backup data by other means or the replacement of the password. This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.The best practice for protecting backups is to store backup tapes in a secure location or back up to disk files that are protected by adequate access control lists (ACLs). The ACLs should be set on the directory root under which backups are created.

Permissions

In SQL Server 2008 (10.0.x) and later versions, obtaining information about a backup set or backup device requires CREATE DATABASE permission. For more information, see GRANT Database Permissions (Transact-SQL).

See Also

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