O'Reilly logo

Writing Stored Procedures for Microsoft SQL Server by Matthew Shepker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Inserting Data with the INSERT Statement

As you know, databases aren't used only for querying data. Databases are also used for storing data. Adding data to a database is done through the use of the INSERT statement, which adds rows to a single table that you specify. For review, the following is the syntax and an explanation of the INSERT 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_hint_limited> ::=
    {     INDEX(index_val [,...n]) | FASTFIRSTROW | HOLDLOCK | PAGLOCK | READCOMMITTED | REPEATABLEREAD | ROWLOCK | SERIALIZABLE | TABLOCK | TABLOCKX ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required