RESTORE DATABASE [DatabaseName]
FROM DISK = N'path\to\backupfile.bak'
WITH [options];
Common options include RECOVERY, NORECOVERY, STANDBY, and REPLACE.
The RESTORE statement restores a backup of a database or transaction log to a database. It can be used to recover a database to a specific point in time, to restore files, or to recover database states after a failure.
RESTORE DATABASE [DatabaseName]
FROM DISK = N'path\to\backupfile.bak'
WITH [options];
Common options include RECOVERY, NORECOVERY, STANDBY, and REPLACE.
RESTORE DATABASE AdventureWorks2019
FROM DISK = N'C:\Backups\AdventureWorks2019_Full.bak'
WITH RECOVERY,
REPLACE;
RESTORE DATABASE AdventureWorks2019
FROM DISK = N'C:\Backups\AdventureWorks2019_Full.bak' WITH NORECOVERY;
RESTORE LOG AdventureWorks2019
FROM DISK = N'C:\Backups\AdventureWorks2019_Log1.trn' WITH NORECOVERY;
RESTORE LOG AdventureWorks2019
FROM DISK = N'C:\Backups\AdventureWorks2019_Log2.trn'
WITH STOPAT = '2024-03-15T14:30:00', RECOVERY;
| Option | Description |
|---|---|
| RECOVERY | Brings the database online after restore. |
| NORECOVERY | Leaves the database non-operational for additional restores. |
| STANDBY | Leaves the database read-only and allows log shipping. |
| REPLACE | Overwrites an existing database without checking for compatibility. |
| MOVE | Specifies new file locations for data and log files. |