Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CREATE TABLE Department
(
DeptID INT NOT NULL PRIMARY KEY CLUSTERED
,DeptName VARCHAR(50) NOT NULL
,ManagerID INT NULL
,SysStartTime DATETIME2 GENERATED ALWAYS AS ROW START NOT NULL
,SysEndTime DATETIME2 GENERATED ALWAYS AS ROW END NOT NULL
,PERIOD FOR SYSTEM_TIME(SysStartTime, SysEndTime)
)
WITH (SYSTEM_VERSIONING = ON)
CREATE TABLE dbo.Manager
(
ManagerID INT NOT NULL PRIMARY KEY
,ManagerName VARCHAR(50) NOT NULL
,SysStartTime DATETIME2(7) GENERATED ALWAYS AS ROW START NOT NULL
,SysEndTime DATETIME2(7) GENERATED ALWAYS AS ROW END NOT NULL
,PERIOD FOR SYSTEM_TIME(SysStartTime, SysEndTime)
)
WITH (SYSTEM_VERSIONING = ON)
GO
INSERT INTO dbo.Manager (ManagerID, ManagerName)
VALUES
( 1 -- ManagerID - int
,'Greg' -- ManagerName - varchar(50)
)
INSERT INTO dbo.Department (DeptID, DeptName, ManagerID)
VALUES
( 1 -- DeptID - int
,'Sales' -- DeptName - varchar(50)
,1 -- ManagerID - int
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.