Inspectopedia
 
2024.3

Insert NULL into NOT NULL column

Warning
New
Last modified: 03 December 2024

Reports cases when you insert NULL values into columns that accept only NOT NULL values.

Example (Microsoft SQL Server):

You cannot insert NULL values in col1 and col2 because they are defined as NOT NULL. If you run the script as is, you will receive an error. To fix this code, replace NULL in the VALUES part with some values (for example, 42 and 'bird').

INSERT INTO br2 (id, col1, col2) VALUES (1, 42, 'bird');