Redigera

Dela via


View the contents of a backup tape or file (SQL Server)

Applies to: SQL Server

This topic describes how to view the content of a backup tape or file in SQL Server by using SQL Server Management Studio or Transact-SQL.

Note

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

For information about security, see RESTORE HEADERONLY (Transact-SQL).

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).

Using SQL Server Management Studio

To view the content of a backup tape or file

  1. After connecting to the appropriate instance of the Microsoft 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.

Using Transact-SQL

To view the content of a backup tape or file

  1. Connect to the Database Engine.

  2. From the Standard bar, click New Query.

  3. Use the RESTORE HEADERONLY statement. This example returns information about the file named AdventureWorks2022-FullBackup.bak.

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

See Also

backupfilegroup (Transact-SQL)
backupfile (Transact-SQL)
backupset (Transact-SQL)
backupmediaset (Transact-SQL)
backupmediafamily (Transact-SQL)
Backup Devices (SQL Server)
Define a Logical Backup Device for a Disk File (SQL Server)
Define a Logical Backup Device for a Tape Drive (SQL Server)