Skip to content

Instantly share code, notes, and snippets.

@juanonsoftware
Created October 22, 2018 08:30
Show Gist options
  • Select an option

  • Save juanonsoftware/b39cf95e3ea757ff758b79d42e1f7c59 to your computer and use it in GitHub Desktop.

Select an option

Save juanonsoftware/b39cf95e3ea757ff758b79d42e1f7c59 to your computer and use it in GitHub Desktop.
Restore a SQL Server database from backup files
-- 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