Επεξεργασία

Κοινή χρήση μέσω


Restore a Backup from a Device (SQL Server)

Applies to: SQL Server

This topic describes how to restore a backup from a device in SQL Server by using SQL Server Management Studio or Transact-SQL.

Note

For information on SQL Server backup to Azure Blob Storage, see, SQL Server Backup and Restore with Microsoft Azure Blob Storage.

In This Topic

Before You Begin

Security

Permissions

If the database being restored does not exist, the user must have CREATE DATABASE permissions to be able to execute RESTORE. If the database exists, RESTORE permissions default to members of the sysadmin and dbcreator fixed server roles and the owner (dbo) of the database (for the FROM DATABASE_SNAPSHOT option, the database always exists).

RESTORE permissions are given to roles in which membership information is always readily available to the server. Because fixed database role membership can be checked only when the database is accessible and undamaged, which is not always the case when RESTORE is executed, members of the db_owner fixed database role do not have RESTORE permissions.

Using SQL Server Management Studio

To restore a backup from a device

  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, point to Tasks, and then click Restore.

  4. Click the type of restore operation you want (Database, Files and Filegroups, or Transaction Log). This opens the corresponding restore dialog box.

  5. On the General page, in the Restore source section, click From device.

  6. Click the browse button for the From device text box, which opens the Specify Backup dialog box.

  7. In the Backup media text box, select Backup Device, and click the Add button to open the Select Backup Device dialog box.

  8. In the Backup device text box, select the device you want to use for the restore operation.

Using Transact-SQL

To restore a backup from a device

  1. Connect to the Database Engine.

  2. From the Standard bar, click New Query.

  3. In the RESTORE statement, specify a logical or physical backup device to use for the backup operation. This example restores from a disk file that has the physical name Z:\SQLServerBackups\AdventureWorks2022.bak.

RESTORE DATABASE AdventureWorks2022  
   FROM DISK = 'Z:\SQLServerBackups\AdventureWorks2022.bak' ;  
  

See Also

RESTORE FILELISTONLY (Transact-SQL)
RESTORE HEADERONLY (Transact-SQL)
RESTORE LABELONLY (Transact-SQL)
RESTORE VERIFYONLY (Transact-SQL)
Restore a Database Backup Under the Simple Recovery Model (Transact-SQL)
Restore a Database Backup Using SSMS
Restore a Differential Database Backup (SQL Server)
Restore a Database to a New Location (SQL Server)
Back Up Files and Filegroups (SQL Server)
Back Up a Transaction Log (SQL Server)
Create a Differential Database Backup (SQL Server)