INSERT

Add a new row to a table or view.

Syntax
      [WITH common_table_expression [ ,...n ] ]
        INSERT 
           [TOP (expression) [PERCENT] ] 
             [INTO] {object | rowset_function_limited 
                      [WITH ( Table_Hint_Limited [ ...n ] ) ]
                    }
      {
       [( column_list )] [OUTPUT_Clause] VALUES ( { DEFAULT | NULL | expression } [ ,...n ])
       derived_table 
       execute_statement 
      } 
      | DEFAULT VALUES 
      [; ]

   object:
     server.database.schema.table_or_view
     database.[schema].table_or_view
     schema.table_or_view

Key
   TOP            The number or percent of random rows that will be inserted.
   rowset_function_limited  Either the OPENQUERY or OPENROWSET function.
   OUTPUT..       Return the inserted rows.
   VALUES         Supply a list of data values to be inserted.
   DEFAULT        Load the column's default value (or NULL).
   DEFAULT VALUES Load defaults for all columns

When an INSTEAD OF trigger is defined on INSERT actions against a table or view, the trigger executes instead of the INSERT statement.

Examples

INSERT INTO Table01
VALUES ('Character data',1);
GO

INSERT INTO Table02
VALUES (NEWID(),'Character data');
GO

"When debugging, novices insert corrective code; experts remove defective code” ~ Richard Pattis

Related commands

BULK INSERT
CREATE TABLE
DELETE
EXECUTE
IDENTITY (Property)
NEWID
SELECT
SET ROWCOUNT
UPDATE
Equivalent Oracle command: INSERT


 
Copyright © 1999-2024 SS64.com
Some rights reserved