INSERT INTO SELECT Statement
In this article describe about Insert data one table to existing table The INSERT INTO SELECT statement selects data from one table and inserts it into an existing table.
Example
In this article Firstly create 2 tables like - tbl_1,tbl_2 and insert some values in tbl_1 Using 'INSERT INTO' Statement data Insert into tbl_2 table , you will find all records in tbl_2 tableCreate Table
(
Id int,
name nvarchar(10)
)
Note -
Table tbl_1 created with two field and same for tbl_2 with same field and datatype, name may be different but datatype sameAbove Example Created Table tbl_1 after that Use Insert into Statement
Syntex
Note -
INSERT INTO [TableName]SELECT * FROM [TableName]
You also see example then you can better understand
Example
SELECT * FROM tbl_1
Note -
In this example Tbl_2 inserted all record which are in tbl_1, You can see above using select statementSELECT * FROM tbl_2
SELECT INTO STATEMENT
you can want to make replica of table then use select into
select * into tbl_2 from tbl_1 In this no need create table ,following example we can't create table tbl_2 only create tbl_1 and just make replica so table and data same copy in replica of table this is explain in my previous article