Sql – Copy data into another table

sqlsql serversql-server-2008

How to copy/append data from one table into another table with same schema in SQL Server?

Edit:

let's say there is a query

select * 
into table1 
from table2 
where 1=1 

which creates table1 with the same schema as well as data as in table2.

Is there any short query like this to only copy entire data only into an already existing table?

Best Answer

If both tables are truly the same schema:

INSERT INTO newTable
SELECT * FROM oldTable

Otherwise, you'll have to specify the column names (the column list for newTable is optional if you are specifying a value for all columns and selecting columns in the same order as newTable's schema):

INSERT INTO newTable (col1, col2, col3)
SELECT column1, column2, column3
FROM oldTable