SQL for Beginners
About Lesson

INSERT INTO

The INSERT INTO statement is used to insert a new row in a table. It is possible to write the INSERT INTO statement in two forms.

The first form doesn’t specify the column names where the data will be inserted, only their values:

Example:

 

The second form specifies both the column names and the values to be inserted:

This form is recommended!

Example:

 

Insert Data Only in Specified Columns:

It is also possible to only add data in specific columns.

Example:

Note! You need at least to include all columns that cannot be NULL.

We remember the table definition for the CUSTOMER table:

i.e., we need to include at least “CustomerNumber”, “LastName” and “FirstName”. “CustomerId” is set to “identity(1,1)” and therefore values for this column are generated by the system.

 

Insert Data in the Designer Tools:

When you have created the tables, you can easily insert data into them using the designer tools. Right-click on the specific table and select “Edit Top 200 Rows”:

Then you can enter data in a table format, similar to, e.g., MS Excel: