Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Inserting data
5. Insert NULL values
Modifying data
Deleting data
CRUD

Instruction

Well done! You can use the NULL value explicitly in an INSERT statement. To insert Chris of unknown age as a user with an ID of 6, you can use the command:

INSERT INTO User (Id, Name, Age) 
VALUES (6, N'Chris', NULL);

Or, since the command defines values for all columns in the User table, you can simply use this command:

INSERT INTO User 
VALUES (6, N'Chris', NULL);

Which way should you choose: The one presented in the previous exercise or one of the ways shown here? It's entirely up to you! If you want to emphasize that you insert a NULL value, insert it explicitly. If you want to save some typing, omit the column name.

Exercise

Add the starter Kosovo Bread with ID 10 again into the Dish table. This time, explicitly insert a NULL value into the Price column.

Stuck? Here's a hint!

Type

INSERT INTO Dish 
VALUES (10, N'starter', N'Kosovo Bread', NULL);