Created
March 3, 2017 13:58
-
-
Save vicneanschi/c3a3f4762531f8074624c2a80c737d40 to your computer and use it in GitHub Desktop.
MSSQL create/restore snapshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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