William
William

Reputation: 6610

Inserting all records of a table into another

Currently I'm running a query like this to add fields from one table into another.

 INSERT INTO new_table (Num1, Num2, Num3)
 SELECT Num1, Num2, Num3
 FROM initial_table

My table contains many different columns, is there a way to move them all with one command rather than manually type each and every column?

Upvotes: 0

Views: 75

Answers (2)

Yaroslav
Yaroslav

Reputation: 6534

If your tables are indentical, columns are in exactly same order and there are no IDENTITY columns you could do this:

INSERT INTO new_table
SELECT *
  FROM initial_table

Upvotes: 1

Mikael Eriksson
Mikael Eriksson

Reputation: 138970

INSERT INTO new_table
SELECT *
FROM initial_table

Will however not work if you have a identity column in new_table.

Upvotes: 1

Related Questions