Adding Data

Accessing and Changing Relational Data

Accessing and Changing Relational Data

Adding Data

Microsoft® SQL Server™ supports these ways to add data to a table:

  • The INSERT statement with one of two options:
    • A VALUES clause to insert one row with a specific set of values.

    • A SELECT subquery to insert data selected from a table or view.
  • Database application programming interfaces (APIs)

    Support options for inserting data while processing a result set.

  • The WRITETEXT statement and several database API options

    Can be used to add ntext, text, or image data to a row.

  • Functions in the database APIs (ADO, OLE DB, ODBC, and DB-Library)

    Support adding new ntext, text, and image data to a row.

  • The SELECT INTO statement

    Can be used to create a new table containing all the rows of the SELECT INTO result set.

  • The bulk copy component for inserting large numbers of rows

    There are three main ways to specify bulk copy operations:

    • The bulk copy program (the bcp utility), a command prompt utility.

    • The BULK INSERT statement used in Transact-SQL batches, stored procedures, and triggers.

    • The bulk copy APIs for OLE DB, ODBC, and DB-Library applications.

INSERT statements work on views as well as on tables, with some restrictions. For more information, see Creating a View.