ALTER TABLE #Students
ADD CONSTRAINT chk_period CHECK (Period IN (1,2,3,4))
✓
hidden batch(es)
INSERT INTO
#Students([Name],[Surname],[Period],[Sport],[History],[English],[Geography])
VALUES
('Mary','Brown',1,17,15,NULL,30)
1 rows affected
hidden batch(es)
INSERT INTO
#Students([Name],[Surname],[Period],[Sport],[History],[English],[Geography])
VALUES
('Luke','Green',5,30,20,23,NULL)
Msg 547 Level 16 State 0 Line 1
The INSERT statement conflicted with the CHECK constraint "chk_period". The conflict occurred in database "tempdb", table "dbo.#Students___________________________________________________________________________________________________________000000000049", column 'Period'.
Msg 3621 Level 0 State 0 Line 1
The statement has been terminated.