Altering temporal tables

You can use the ALTER TABLE statement to perform schema changes on system-versioned temporal tables. When you use it to add a new data type, change a data type, or remove an existing column, the system will automatically perform the action against both the current and the history table. However, some of these actions will not be metadata operations only; there are changes that will update the entire table.

To check this, run the following code to create (and populate with sample data) the temporal table from the previous section:

USE tempdb; CREATE TABLE dbo.Product ( ProductId INT NOT NULL CONSTRAINT PK_Product PRIMARY KEY, ProductName NVARCHAR(50) NOT NULL, Price MONEY NOT NULL, ValidFrom DATETIME2 GENERATED ALWAYS ...

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.