檢視備份磁帶或檔案的內容 (SQL Server)View the Contents of a Backup Tape or File (SQL Server)

適用於: 是SQL Server 否Azure SQL Database 否Azure SQL 資料倉儲 否平行處理資料倉儲 APPLIES TO: yesSQL Server noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

此主題描述如何使用 SQL Server 2017SQL Server 2017SQL Server Management StudioSQL Server Management Studio ,在 Transact-SQLTransact-SQL中檢視備份磁帶或檔案的內容。This topic describes how to view the content of a backup tape or file in SQL Server 2017SQL Server 2017 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

安全性Security

如需安全性的相關資訊,請參閱 RESTORE HEADERONLY (Transact-SQL)For information about security, see RESTORE HEADERONLY (Transact-SQL).

PermissionsPermissions

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 Database EngineSQL Server Database Engine執行個體之後,在 [物件總管] 中按一下伺服器名稱展開伺服器樹狀目錄。After connecting to the appropriate instance of the MicrosoftMicrosoft SQL Server Database EngineSQL 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 EngineDatabase EngineConnect to the Database EngineDatabase 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)