RESTORE
RESTORE is a Transact-SQL statement in SQL Server used to retrieve or recover data from a backup. It performs operations such as restoring data, transaction logs, and files groups from a backup, replacing existing databases, or creating a new database. It is an essential command for disaster recovery scenarios.
Example
Output
Explanation
The given code is used to restore a SQL Server database named ‘TestDB’ from a backup file located at ‘C:\BackupFolder\TestDB.bak’. The ‘WITH RECOVERY’ option brings the database online immediately after the restore operation is finished. The output indicates the process of restoration in percentages and confirms successful restoration upon completion.
Example
Output
Explanation
The above example script runs restore and recovery on a database up to System Change Number (SCN) 1000. If you know the SCN, you can use it to recover the database to a specific point in time.