Inserting Rows

To add data to a table in the database, you would generally use the INSERT statement. The INSERT statement appends one or more rows of data to a table. The syntax for the INSERT statement follows, with Table 7.1 describing the main arguments of the statement.

INSERT [ INTO]
    {  table_name WITH ( < table_hint_limited > [ …n ] )
         | view_name
         | rowset_function_limited
    }
    {     [ ( column_list ) ]
         {  VALUES
              ( {  DEFAULT | NULL | expression }  [ ,…n] )
              | derived_table
              | execute_statement
         }
    }
    |  DEFAULT VALUES
    }
Table 7.1. Insert Statement Arguments
Argument Description
[INTO] Optional keyword used to specify the table to be used when inserting data.
table_name Name of the table where the data is being inserted.
WITH (<table_hint_limited> Specifies ...

Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.