So I can't have NOT NULL in column definition of temporal tables?

Viewed 1418

I am using SQL Server 2016 and trying to create Temporal table. Here is the definition:

USE zbachoreTest
GO`enter code here`
IF EXISTS (SELECT 1 FROM sys.tables WHERE name = 'People' AND temporal_type_desc ='SYSTEM_VERSIONED_TEMPORAL_TABLE' )
ALTER TABLE dbo.People SET( SYSTEM_VERSIONING = OFF)
DROP TABLE IF EXISTS dbo.People 
CREATE TABLE dbo.People(
    PersonID INT IDENTITY(1,1) NOT NULL CONSTRAINT PK_People PRIMARY KEY(PersonID),
    FirstName VARCHAR(50) NOT  NULL,
    LastName VARCHAR(50)  NULL,
    StartTime DATETIME2 GENERATED ALWAYS AS ROW START NOT NULL
        CONSTRAINT DF_People_StartTime DEFAULT SYSDATETIME(),
    EndTime DATETIME2 GENERATED ALWAYS AS ROW END NOT NULL
        CONSTRAINT DF_People_EndTime DEFAULT CONVERT(DATETIME2,'9999-12-31 23:59:59.9999999'),
    PERIOD FOR SYSTEM_TIME(StartTime,EndTime)
    ) WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.PeopleHistory))

when I run the above code, I am getting the following error message: Msg 13531, Level 16, State 1, Line 7 Setting SYSTEM_VERSIONING to ON failed because column 'FirstName' does not have the same nullability attribute in tables 'zbachoreTest.dbo.People' and 'zbachoreTest.dbo.PeopleHistory'.

Any smart folks out there please help. Thanks!

1 Answers
Related