Created
October 22, 2018 08:30
-
-
Save juanonsoftware/b39cf95e3ea757ff758b79d42e1f7c59 to your computer and use it in GitHub Desktop.
Restore a SQL Server database from backup files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Get all db files from a bak | |
| RESTORE FILELISTONLY | |
| FROM DISK = 'Path to full backup file' | |
| GO | |
| -- Restore database from a bak with move logical files (note on NORECOVERY) | |
| RESTORE DATABASE FindTheBest FROM DISK = 'Path to full backup file' | |
| WITH MOVE 'Data file 1' TO 'Path to data file', | |
| MOVE 'Log file 1' TO 'Path to log file', | |
| NORECOVERY | |
| GO | |
| -- Restore database from a diff backup | |
| RESTORE DATABASE FindTheBest FROM DISK = 'Path to diff backup file' | |
| GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment