Adds a new row to a table or a view.
Examples
1. Use a simple INSERT
Insert into table_name VALUES (1, 'Row #1')
2.Insert data that is not in the same order as the columns
Insert into table_name (column_2, column_1) VALUES ('Row #1',1)
3. Insert data with fewer values than columns
i. Insert into table_name (column_4) VALUES ('Explicit value')
ii. Insert into table_name (column_2,column_4) VALUES ('Explicit value', 'Explicit value')
iii.Insert into table_name (column_2,column_3,column_4) VALUES ('Explicit value',-44,'Explicit value')
4.Load data into a table with an identity column
SET IDENTITY_INSERT T1 ON INSERT INTO T1 (column_1,column_2) VALUES (-99,'Explicit identity value')
5 .Insert data using the TOP clause in a SELECT statement
INSERT INTO new_authors SELECT TOP 10 * FROM authors
6. Insert data using default values options
insert into table_name default values
Labels
- AVG() Function (1)
- Aggregate Functions (1)
- Candidate Key (1)
- Composite and Compound Keys (1)
- EXISTS (1)
- FIRST() Function (1)
- Group By Statement (1)
- Having Clause (1)
- INSERT (1)
- LIKE (1)
- SELECT AS CLAUSE (1)
- SQL Distinct Unique Records (1)
- SQL IN (1)
- SQL Joins (1)
- SQL Last() Function (1)
- SQL NULL Conditional (1)
- SQL Not Exists (1)
- SQLComparison Operators (1)
- Sql Max() Function (1)
- Sql Min() Function (1)
- Sql SUM() Function (1)
- WHERE (1)
Blog Archive
-
▼
2010
(73)
-
▼
April
(21)
- Monthly Count at Column Level
- SQL SUM() Function
- SQL Min() Function
- SQL Max() Function
- SQL Last() Function
- SQL Not Exists
- FIRST() Function
- COUNT() function
- The AVG() Function
- SQL Aggregate Functions
- Group By Statement
- HAVING Clause
- SQL Joins
- Full Text Search
- CONTAINS Predicate
- WHERE Clause
- EXISTS
- Like Operator
- UNION/INTERSECT CLAUSES
- INSERT Statement Syntax
- SELECT - SQL Command
-
▼
April
(21)
Thursday, April 8, 2010
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment