Skip to content

Instantly share code, notes, and snippets.

@vicneanschi
Created March 3, 2017 13:58
Show Gist options
  • Save vicneanschi/c3a3f4762531f8074624c2a80c737d40 to your computer and use it in GitHub Desktop.
Save vicneanschi/c3a3f4762531f8074624c2a80c737d40 to your computer and use it in GitHub Desktop.
MSSQL create/restore snapshot
--THis works only on local
USE Master
go
--Adjust Name as per logical name of the file() (database properties: Files), Ignore Log files
--Adjust FileName to where you want the snapshot to exists: it requires the same size of the original DB
CREATE DATABASE MySnap
ON (NAME = N'MyDB', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL13.SQLSERVER2016\MSSQL\DATA\MyDB.snap')
AS SNAPSHOT OF MyDB;
GO
/*
--When you want to go back to your snapshot:
RESTORE DATABASE CashTrak FROM DATABASE_SNAPSHOT = 'MySnap'
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment