Copy Data From One Table to Another with SQL

Let’s say you have two tables in your SQL database. One is called Table1 and has columns called Column1 and Column2. And the other is called Table2 with columns of the same name. An easy way to copy from Table1 to Table2 would be with the following SQL statement.

INSERT INTO Table1
SELECT * FROM Table2

However, let’s say Table1 has Column1, Column2, and Column3, but you only have two columns in Table2: Column1 and Column3. You could copy Column1 and Column3 with the following statement.

INSERT INTO Table1
SELECT Column1, Column3
FROM Table2

And of course you can use a WHERE clause on the SELECT statement to filter what you copy.

Leave a Reply