Skip to content

Instantly share code, notes, and snippets.

@jackawatts
Last active July 18, 2018 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackawatts/efc150a6889596a854a4472b150ddae7 to your computer and use it in GitHub Desktop.
Save jackawatts/efc150a6889596a854a4472b150ddae7 to your computer and use it in GitHub Desktop.

Restoring a database to LocalDB

from: http://www.alteridem.net/2016/03/24/restore-a-sql-server-backup-to-localdb/

  1. Visual Studio
  2. SQL Server Object Explorer (Ctrl+S, Ctrl+)
  3. Master => New Query
  RESTORE FILELISTONLY
  FROM DISK = 'C:\Temp\database.bak'
  1. Note the names in the 'Logical Names' column from the result
  2. Restore the backup
  RESTORE DATABASE Database
  FROM DISK = 'C:\Temp\database.bak'

  WITH MOVE '<data_logical_name_from_the_reults_above>' TO 'C:\Users\admin\database.mdf',
  MOVE '<log_logical_name_from_the_reults_above>' TO 'C:\Users\admin\database.ldf',
  REPLACE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment