Skip to content

Commit 29334f6

Browse files
author
AbhishekMallick01
committed
minor changes
1 parent 124c954 commit 29334f6

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

articles/backup/restore-sql-database-azure-vm.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,28 +197,29 @@ To restore the database files to the *original path on the source server*, remov
197197
198198
**Example**
199199

200-
```
201-
USE [master]
202-
RESTORE DATABASE [<DBName>] FROM  DISK = N'<.bak file path>'
203-
```
200+
201+
```azurecli-interactive
202+
USE [master]
203+
RESTORE DATABASE [<DBName>] FROM  DISK = N'<.bak file path>'
204+
```
204205

205206
>[!Note]
206207
>You shouldn’t have the same database files on the target server (restore with replace).  Also you can [enable instant file initialization on the target server to reduce the file initialization time overhead]( /sql/relational-databases/databases/database-instant-file-initialization?view=sql-server-ver16).
207208

208209
To relocate the database files from the target restore server, you can frame a TSQL command using the `MOVE` clauses.
209210

210-
```
211-
USE [master]
212-
RESTORE DATABASE [<DBName>] FROM  DISK = N'<.bak file path>'  MOVE N'<LogicalName1>' TO N'<TargetFilePath1OnDisk>',  MOVE N'<LogicalName2>' TO N'<TargetFilePath2OnDisk>' GO
213-
```
211+
```azurecli
212+
USE [master]
213+
RESTORE DATABASE [<DBName>] FROM  DISK = N'<.bak file path>'  MOVE N'<LogicalName1>' TO N'<TargetFilePath1OnDisk>',  MOVE N'<LogicalName2>' TO N'<TargetFilePath2OnDisk>' GO
214+
```
214215

215216
**Example**
216-
217-
```
218-
USE [master]
219-
RESTORE DATABASE [test] FROM  DISK = N'J:\dbBackupFiles\test.bak' WITH  FILE = 1,  MOVE N'test' TO N'F:\data\test.mdf',  MOVE N'test_log' TO N'G:\log\test_log.ldf',  NOUNLOAD,  STATS = 5
220-
GO
221-
```
217+
218+
```azurecli
219+
USE [master]
220+
RESTORE DATABASE [test] FROM  DISK = N'J:\dbBackupFiles\test.bak' WITH  FILE = 1,  MOVE N'test' TO N'F:\data\test.mdf',  MOVE N'test_log' TO N'G:\log\test_log.ldf',  NOUNLOAD,  STATS = 5
221+
GO
222+
```
222223

223224
If there are more than two files for the database, you can add additional move clauses to the restore query. You can also use SSMS for database recovery using `.bak` files. Learn more on [restoring an SQL database backup using SSMS]( /sql/relational-databases/backup-restore/restore-a-database-backup-using-ssms?view=sql-server-ver16).
224225

0 commit comments

Comments
 (0)