Skip to content

Instantly share code, notes, and snippets.

@Laim
Last active May 27, 2020 12:29
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 Laim/277f17c7fedd9860d8b71aace002a74c to your computer and use it in GitHub Desktop.
Save Laim/277f17c7fedd9860d8b71aace002a74c to your computer and use it in GitHub Desktop.
Restore SQL Server Database
-- Take the database offline before restoring
ALTER DATABASE [DatabaseName]
SET OFFLINE WITH ROLLBACK IMMEDIATE
-- Restore the database
RESTORE DATABASE DatabaseName FROM DISK = '\\FileServer\directory\servername\database\database_backup.bak'
-- Bring it back online, this should be automatic but just incase.
ALTER DATABASE [DatabaseName]
SET ONLINE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment