Article Information
This SQL Tutorial contains and tries to cover following subjects:
- Explanation of Creating table with sql insert in SQL
- Example to Creating table with sql insert in SQL
Articles tries to provide answer to following questions
- How to create a new table when inserting data in SQL?
- How to create a table with selecting data from another table in SQL?
- How to use SELECT INTO in SQL?
- How to create a new table from a SELECT query result in SQL?
Article covers followings indirectly:
- SQL insert command
- SQL select insert
Articles pre-requisites following information:
- General knowledge of SQL Server Management Studio
- General knowledge of INSERT command
SQL INSERT with select had been covered in earlier articles. SQL insert also can be used to create tables, a new table when inserting rows. When SELECT is used to pull data or rows from a table, sql insert can insert that new rows to new table with creating table. It is a method to create tables from another tables or creating tables with filtering another tables or rows.
Idea behind is to create a new table when select brings data.
Lets recall basic sql insert syntax again:
INSERT (column1, column2) VALUES (value1, values2)
To create a new table from SQL insert, following sql insert syntax is used:
SELECT * INTO newtable1 FROM existingTable1 WHERE condition1
Lets see in a sql insert into example which selects some rows from a existing table, to insert another table with creating it in same query.
As above sql SELECT INTO - INSERT example indicates, we selected 4 customer from original customers table, and inserted them to another table with creating a new table in same sql insert command. Creating new table to insert selected rows from a table is an approach to create tables from another.