Events
31 Mar, 11 pm - 2 Apr, 11 pm
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Usually, all of the data in a SQL Server database is restored before the database is recovered. However, a restore operation can recover a database without actually restoring a backup; for example, when recovering a read-only file that is consistent with the database. This is referred to as a recovery-only restore. When offline data is already consistent with the database and needs only to be made available, a recovery-only restore operation completes the recovery of the database and bring the data online.
A recovery-only restore can occur for a whole database or for one or more a files or filegroups.
A recovery-only database restore can be useful in the following situations:
You did not recover the database when restoring the last backup in a restore sequence, and you now want to recover the database to bring it online.
The database is in standby mode, and you want to make the database updatable without applying another log backup.
The RESTORE syntax for a recovery-only database restore is as follows:
RESTORE DATABASE *database_name* WITH RECOVERY
Note
The FROM = <backup_device> clause is not used for recovery-only restores because no backup is necessary.
Example
The following example recovers the AdventureWorks2022
sample database in a restore operation without restoring data.
-- Restore database using WITH RECOVERY.
RESTORE DATABASE AdventureWorks2022
WITH RECOVERY
A recovery-only file restore can be useful in the following situation:
A database is restored piecemeal. After restore of the primary filegroup is complete, one or more of the unrestored files are consistent with the new database state, perhaps because it has been read-only for some time. These files only have to be recovered; data copying is unnecessary.
A recovery-only restore operation brings the data in the offline filegroup online; no data-copy, redo, or undo phase occurs. For information about the phases of restore, see Restore and Recovery Overview (SQL Server).
The RESTORE syntax for a recovery-only file restore is:
RESTORE DATABASE *database_name* { FILE **=**_logical_file_name_ | FILEGROUP **=**_logical_filegroup_name_ }[ **,**...*n* ] WITH RECOVERY
Example
The following example illustrates a recovery-only file restore of the files in a secondary filegroup, SalesGroup2
, in the Sales
database. The primary filegroup has already been restored as the initial step of a piecemeal restore, and SalesGroup2
is consistent with the restored primary filegroup. Recovering this filegroup and bringing it online requires only a single statement.
RESTORE DATABASE Sales FILEGROUP=SalesGroup2 WITH RECOVERY;
Simple recovery model
Example: Piecemeal Restore of Database (Simple Recovery Model)
Example: Piecemeal Restore of Only Some Filegroups (Simple Recovery Model)
Full recovery model
Example: Piecemeal Restore of Database (Full Recovery Model)
Example: Piecemeal Restore of Only Some Filegroups (Full Recovery Model)
Online Restore (SQL Server)
Piecemeal Restores (SQL Server)
File Restores (Simple Recovery Model)
File Restores (Full Recovery Model)
RESTORE (Transact-SQL)
Restore and Recovery Overview (SQL Server)
Events
31 Mar, 11 pm - 2 Apr, 11 pm
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayTraining
Module
Back up and restore your Azure SQL database - Training
Learn how to protect the data in your Azure SQL database and recover from data loss or corruption with backup and restore.
Certification
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.
Documentation
Restore and Recovery Overview (SQL Server) - SQL Server
Learn about the operations involved in recovering a SQL Server database from a failure by restoring a set of SQL Server backups in sequence.
Restart interrupted restore operation - SQL Server
This example shows you how to restart an interrupted restore operation in SQL Server using Transact-SQL.
Restore a SQL Server Database to a Point in Time (Full Recovery Model) - SQL Server
Restore a SQL Server Database to a Point in Time (Full Recovery Model)