Period columns as hidden attributes

Period columns are used to support the temporality of data and have no business logic value. By using the HIDDEN clause, you can hide the new PERIOD columns to avoid impacting on existing applications that are not designed to handle new columns. The following code will create two temporal tables, one with default values (visible period column) and the other with hidden period columns:

CREATE TABLE dbo.T1( 
   Id INT NOT NULL CONSTRAINT PK_T1 PRIMARY KEY, 
   Col1 INT NOT NULL, 
   ValidFrom DATETIME2 GENERATED ALWAYS AS ROW START NOT NULL, 
   ValidTo DATETIME2 GENERATED ALWAYS AS ROW END NOT NULL, 
   PERIOD FOR SYSTEM_TIME (ValidFrom, ValidTo) 
) 
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.T1_Hist)); GOINSERT INTO dbo.T1(Id, ...

Get SQL Server 2017 Developer's Guide 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.