Last active
December 6, 2021 00:46
-
-
Save naradae/99a7358bbb0aae054608455ff7129932 to your computer and use it in GitHub Desktop.
SQL Snapshot Commands
This file contains 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
/* | |
Instructions: | |
- Replace CRONUSLIVE with your database name | |
- Replace 202112031200 with a current timestamp | |
- Replace the database file names and paths with the names from your database. Use SELECT * FROM sys.database_files to assist with this | |
- The snapshot must latest be deleted (with DROP DATABASE CRONUSLIVE_snapshot_202112031200), as it continues to be a drain on all transactions in the source database | |
*/ | |
CREATE DATABASE CRONUSLIVE_snapshot_202112031200 ON ( | |
NAME = [CRONUSLIVE_Data] | |
,FILENAME = 'D:\SQLData\CRONUSLIVE_snapshot_202112031200.mdf' | |
) AS SNAPSHOT OF CRONUSLIVE |
This file contains 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
/* | |
Instructions: | |
- Replace CRONUSLIVE_snapshot_202112031200 with your database name. Use SELECT * FROM sys.databases to see all database names | |
*/ | |
DROP DATABASE CRONUSLIVE_snapshot_202112031200; |
This file contains 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
/* | |
Instructions: | |
- Replace CRONUSLIVE with your database name | |
- Replace CRONUSLIVE_snapshot_202112031200 with the name of your snapshot. Use SELECT * FROM sys.databases to see all database names | |
*/ | |
USE master | |
ALTER DATABASE CRONUSLIVE SET SINGLE_USER WITH ROLLBACK IMMEDIATE; | |
GO | |
ALTER DATABASE CRONUSLIVE SET MULTI_USER; | |
GO | |
RESTORE DATABASE CRONUSLIVE FROM DATABASE_SNAPSHOT = 'CRONUSLIVE_snapshot_202112031200'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment