1INSERT INTO my_table my
2SELECT * FROM another_table an
3WHERE an.col1 > 10;
4
5INSERT INTO my_table (colA, colB)
6SELECT an.col1 AS colA, an.col2 AS colB FROM another_table an
7WHERE an.col1 > 10;
1INSERT INTO dbo.YourTableNameHere
2 SELECT *
3 FROM [SourceServer].[SourceDatabase].dbo.YourTableNameHere
1Let’s assume that, we have our employee table.
2We have to copy this data
3into another table. For this purpose,
4we can use the INSERT INTO SELECT
5operator. Before we go ahead and do that,
6we would have to create another
7table that would have the same structure
8as the given table.
9• First create the second table with
10the same table structure with copied one.
11• Then use the syntax:
12Let’s say employee_duplicate is New table
13employee is First table that we want to copy it into new table
14
15INSERT INTO employee_duplicate SELECT * FROM employee;