Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

SQL Server Restore Database from Backup

$
0
0
[Total: 1 Average: 5/5]

SQL Server restore database from backup how to do it? This is one of the crucial questions related to SQL Server. In this article, we are going to show you two ways how you can do it. The first and the easiest way to make SQL Server database from backup is to useSqlBak. And the second you can use standard T-SQL Commands to restore your SQL Server.

SQL Server Restore Database from Backup

The first and the easiest way to performSQL Server restore database from backup is to use SqlBak. This is thevery simple tool which can create backups according to your schedule and send them to selected destination place on a regular basis. Also, you can simply restore your database from the backup.

SQL Server Restore Database from Backup Using SqlBak

Follow this simple tutorial and learn the way how to performSQL Server restore database from backup with the help ofSqlBak.

Go to your SqlBak Dashboard. Here you can promptly restore the last database backup or select the needed one. If you prefer to restore the last backup press “Restore” button.
SQL Server Restore Database from Backup
If it is necessary to select another database backup press at the backup job and select the backup you are going to restore.
SQL Server Restore Database from Backup
In the “Restore” window you will find SQL Server database backup which you are going to restore. Here you can select where you want to restore your backup on your computer or you can select another computer.
SQL Server Restore Database from Backup
To make SQL Server restore database from backup on your computer simply press “Restore”. If you prefer to restore the backup on different server click “on another computer” link, make all necessary settings and press “Restore”.
SQL Server Restore Database from Backup
You will receive the following message after the restore process will complete.
SQL Server Restore Database from Backup
SQL Server Restore Database from Backup UsingT-SQL Commands

In this a portion of our review, we are going to show how to make SQL Server restore database from backup with the help of T-SQL Commands.

SQL Server Restore Database from a Full Backup

Apply the following T-SQL Command to restore thefull backup of your SQL Server database. That backup will overwrite your database if such is exist or produce a new SQL Server database.

RESTORE DATABASE Adventureworks FROM DISK = 'D:Adventureworks_full.bak'

Once you have restored yourfull database backup you can restore a differential ortransaction logbackups. If you need to do it, restore your full backup using NORECOVERY command. This particular command leaves a backup on restoring state and assists you to restore extra differential ortransaction logbackups.

RESTORE DATABASE Adventureworks FROM DISK = 'D:Adventureworks_full.bak' SQL Server Restore Database from a Differential Backup

The T-SQL Command to restore thedifferential backup is similar as the Command to restore a full backup. All you have to do is don’t skip to add NORECOVERY command.

RESTORE DATABASE Adventureworks FROM DISK = 'D:Adventureworks_full.bak' WITH NORECOVERY
GO
RESTORE DATABASE Adventureworks FROM DISK = 'D:AdventureWorks_diff.dif'
GO SQL Server Restore Database from a Log Backup

If you need to restore a transaction log backup , please don’t forget, that your SQL Server database should be in the restoring state. Which means that it is needed to restore a full backup and adifferential backup, if it needed, earlier.

RESTORE LOG Adventureworks FROM DISK = 'D:Adventureworks_log.trn' SQL Server Restore Database from Multiple Transaction Log Files Using NORECOVERY Option

As we discussed just before you require to add NORECOVERY command to set the database in a restoring state. Under, you will find out the case how to restore your SQL Server database with the help of the next restore scenarios:

Full backup Differential backup Transaction log backup 1 Transaction Log backup 2 RESTORE DATABASE Adventureworks FROM DISK = 'D:\Adventureworks_full.bak' WITH NORECOVERY
GO
RESTORE DATABASE Adventureworks FROM DISK = 'D:\Adventureworks_diff.dif' WITH NORECOVERY
GO
RESTORE LOG Adventureworks FROM DISK = 'D:\Adventureworks_log1.trn' WITH NORECOVERY
GO
RESTORE LOG Adventureworks FROM DISK = 'D:\Adventureworks_log2.trn' WITH RECOVERY
GO

Viewing all articles
Browse latest Browse all 3160

Trending Articles