Configuring the retention policy at the table level

To configure the retention policy, you need to specify a value for the HISTORY_RETENTION_PERIOD parameter during table creation or after the table is created. Use the following code to create and populate a sample temporal table:

USE WideWorldImporters;GOCREATE TABLE dbo.T1(    Id INT NOT NULL PRIMARY KEY CLUSTERED,    C1 INT,    Vf DATETIME2 NOT NULL,    Vt DATETIME2 NOT NULL ) GOCREATE TABLE dbo.T1_Hist(    Id INT NOT NULL,    C1 INT,    Vf DATETIME2 NOT NULL,    Vt DATETIME2 NOT NULL ) GO--populate tablesINSERT INTO dbo.T1_Hist(Id, C1, Vf, Vt) VALUES(1,1,'20171201','20171210'),(1,2,'20171210','20171215');GOINSERT INTO dbo.T1(Id, C1, Vf, Vt) VALUES(1,3,'20171215','99991231 23:59:59.9999999');GO

Here is the content ...

Get Mastering SQL Server 2017 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.