Created
November 1, 2017 20:38
-
-
Save EricCote/b77b9203930ac2178ee79a43d8fd145d to your computer and use it in GitHub Desktop.
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
USE [master]; | |
CREATE DATABASE AdventureWorks_Snapshot_1nov2017 | |
ON ( NAME = N'AdventureWorks', | |
FILENAME = N't:\snap.mdf' ) | |
AS SNAPSHOT OF AdventureWorks; | |
GO | |
------------------------------------- | |
USE AdventureWorks; | |
SELECT * FROM Person.CountryRegion; | |
DELETE FROM Person.CountryRegion | |
WHERE CountryRegionCode LIKE 'Y%'; | |
SELECT * FROM Person.CountryRegion; | |
INSERT INTO AdventureWorks.Person.CountryRegion | |
SELECT s.* | |
FROM AdventureWorks_Snapshot_1nov2017.Person.CountryRegion AS S | |
LEFT JOIN AdventureWorks.Person.CountryRegion AS C | |
ON S.CountryRegionCode=c.CountryRegionCode | |
WHERE C.CountryRegionCode IS NULL; | |
SELECT * FROM Person.CountryRegion; | |
------------------------- | |
USE master; | |
RESTORE DATABASE AdventureWorks FROM | |
DATABASE_SNAPSHOT = 'AdventureWorks_Snapshot_1nov2017'; | |
GO | |
DROP DATABASE AdventureWorks_Snapshot_1nov2017; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment