Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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