Enabling Temporal Table on In-Memory OLTP Table

SELECT * FROM Sales.SpecialOfferProduct_inmem

ALTER TABLE Sales.SpecialOfferProduct_inmem
ADD StartTime DATETIME2
GO

ALTER TABLE Sales.SpecialOfferProduct_inmem
ADD EndTime DATETIME2
GO

UPDATE Sales.SpecialOfferProduct_inmem SET StartTime = ‘19000101 00:00:00.0000000’, EndTime = ‘99991231 23:59:59.9999999’
GO

ALTER TABLE Sales.SpecialOfferProduct_inmem
ALTER COLUMN StartTime DATETIME2 NOT NULL
GO

ALTER TABLE Sales.SpecialOfferProduct_inmem
ALTER COLUMN EndTime DATETIME2 NOT NULL
GO

ALTER TABLE Sales.SpecialOfferProduct_inmem
ADD PERIOD FOR SYSTEM_TIME (StartTime, EndTime)
ALTER TABLE Sales.SpecialOfferProduct_inmem
SET(SYSTEM_VERSIONING = ON (HISTORY_TABLE = Sales.SpecialOfferProduct_inmem_History, DATA_CONSISTENCY_CHECK = ON))
GO

Leave a Reply

Your email address will not be published. Required fields are marked *