BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
There are various ways to insert data into new or existing tables in T-SQL - this blog gives examples of each.
- Inserting Data into Tables using SQL (this blog)
- Inserting Single Records into a Table
- Inserting Multiple Rows of Data into a Table
- SELECT INTO - Making a New Table from Existing Rows
This blog is part of a full online tutorial in SQL. Please have a look too at our introductory and advanced SQL training courses for businesses like yours.
Posted by Andy Brown on 12 October 2012
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Inserting Data into Tables using SQL
A previous blog showed how to create tables using SQL - this one shows how to populate them with data.
When I was first learning SQL, these were some of the commands that I found the hardest to remember. The problem is that there are 3 ways to do this, and each does a different thing. The 3 ways are:
Method | What it does |
---|---|
INSERT INTO ... VALUES | Inserts a single record into a table. |
INSERT INTO ... SELECT | Adds a set of rows into a table. |
SELECT ... INTO | Creates a new tables from a set of rows. |
Aficionados (aficionadi?) of Access should note that the above methods correspond to append and make-table queries.
This blog will consider each of the 3 methods shown above in turn!
- Inserting Data into Tables using SQL (this blog)
- Inserting Single Records into a Table
- Inserting Multiple Rows of Data into a Table
- SELECT INTO - Making a New Table from Existing Rows