查看备份磁带或文件的内容 (SQL Server)View the contents of a backup tape or file (SQL Server)

适用对象:是SQL Server 否Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库 APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

本主题说明如何使用 SQL Server 2019 (15.x)SQL Server 2019 (15.x)SQL Server Management StudioSQL Server Management StudioTransact-SQLTransact-SQL中查看备份磁带或文件的内容。This topic describes how to view the content of a backup tape or file in SQL Server 2019 (15.x)SQL Server 2019 (15.x) by using SQL Server Management StudioSQL Server Management Studio or Transact-SQLTransact-SQL.

备注

在 SQL Server 的未来版本中将不再支持磁带备份设备。Support for tape backup devices 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.

本主题内容In This Topic

开始之前Before You Begin

SecuritySecurity

有关安全性的信息,请参阅 RESTORE HEADERONLY (Transact SQL)For information about security, see RESTORE HEADERONLY (Transact-SQL).

权限Permissions

SQL Server 2008SQL Server 2008 和更高版本中,获取有关备份集或备份设备的信息要求具有 CREATE DATABASE 权限。In SQL Server 2008SQL Server 2008 and later versions, obtaining information about a backup set or backup device requires CREATE DATABASE permission. 有关详细信息,请参阅 GRANT 数据库权限 (Transact-SQL)For more information, see GRANT Database Permissions (Transact-SQL).

使用 SQL Server Management StudioUsing SQL Server Management Studio

查看备份磁带或文件的内容To view the content of a backup tape or file

  1. 连接到相应的 MicrosoftMicrosoft SQL Server 数据库引擎SQL Server Database Engine 实例之后,在“对象资源管理器”中,单击服务器名称以展开服务器树。After connecting to the appropriate instance of the MicrosoftMicrosoft SQL Server 数据库引擎SQL Server Database Engine, in Object Explorer, click the server name to expand the server tree.

  2. 展开 “数据库” ,然后根据数据库的不同,选择用户数据库,或展开 “系统数据库” ,再选择系统数据库。Expand Databases, and, depending on the database, either select a user database or expand System Databases and select a system database.

  3. 右键单击要备的数据库,指向 “任务”,再单击 “备份”。Right-click the database you want to backup, point to Tasks, and then click Back Up. 将出现 “备份数据库” 对话框。The Back Up Database dialog box appears.

  4. “常规” 页的 “目标” 部分中,单击 “磁盘”“磁带”In the Destination section of the General page, click either Disk or Tape. “备份到” 列表框中,查找所需的磁盘文件或磁带。In the Back up to list box, look for the disk file or tape you want.

    如果磁盘文件或磁带未显示在列表框中,请单击 “添加”。If the disk file or tape is not displayed in the list-box, click Add. 选择一个文件名或磁带机。Select a file name or tape drive. 若要将其添加到 “备份到”列表框,请单击 “确定”。To add it to the Back up to list-box, click OK.

  5. 在 “备份到”列表框中,选择要查看的磁盘或磁带机的路径,再单击 “内容”。In the Back up to list-box, select the path of the disk or tape drive you want to view, and click Contents. 将打开 “设备内容” 对话框。This opens the Device Contents dialog box.

  6. 右侧窗格显示有关所选磁带或文件上的介质集和备份集的信息。The right-hand pane displays information about the media set and backup sets on the selected tape or file.

使用 Transact-SQLUsing Transact-SQL

查看备份磁带或文件的内容To view the content of a backup tape or file

  1. 连接到 数据库引擎Database EngineConnect to the 数据库引擎Database Engine.

  2. 在标准菜单栏上,单击 “新建查询”From the Standard bar, click New Query.

  3. 使用 RESTORE HEADERONLY 语句。Use the RESTORE HEADERONLY statement. 此示例将返回有关名为 AdventureWorks2012-FullBackup.bak的文件的信息。This example returns information about the file named AdventureWorks2012-FullBackup.bak.

USE AdventureWorks2012;  
RESTORE HEADERONLY   
FROM DISK = N'C:\AdventureWorks2012-FullBackup.bak' ;  
GO  

另请参阅See Also

backupfilegroup (Transact-SQL) backupfilegroup (Transact-SQL)
backupfile (Transact-SQL) backupfile (Transact-SQL)
backupset (Transact-SQL) backupset (Transact-SQL)
backupmediaset (Transact-SQL) backupmediaset (Transact-SQL)
backupmediafamily (Transact-SQL) backupmediafamily (Transact-SQL)
备份设备 (SQL Server) Backup Devices (SQL Server)
为磁盘文件定义逻辑备份设备 (SQL Server) Define a Logical Backup Device for a Disk File (SQL Server)
为磁带驱动器定义逻辑备份设备 (SQL Server)Define a Logical Backup Device for a Tape Drive (SQL Server)