Insert columns from one table to another

Insert columns from one table to another

Post by Robert Edward » Sat, 25 Jan 2003 04:36:01

I have imported some Access tables into a SQL DB. Every table has
contact first and lastnames and I want to take those two columns from
every imported table and insert them into one new table.

How do I do this? SELECT INTO puts them into a new table, but I want to
create the table and keep inserting.



*** Sent via Developersdex ***
Don't just participate in USENET...get rewarded for it!


Insert columns from one table to another

Post by Anith Se » Sat, 25 Jan 2003 04:39:21

You can do INSERT ...SELECT ..FROM statement to do this,

CREATE TABLE Newtbl (col1, col2,...)
INSERT Newtbl (col1, col2,...)
SELECT col1, col2, ...
  FROM tbl1
SELECT col1, col2, ...
  FROM tbl2

- Anith
(Please respond only to newsgroups)


1. inserting multible columns from one table into a single column in another table

example:  in gupta I could write the following sql statement to insert
multible columns from one table into a singe column in another table.

insert into receipttable (id,name) select id,firstname|| ' ' lastname
from mastertbl where id=1


1,Angelique Worrell

sql server 7.0  -- i get the following error:

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '|'.

How is this done?


2. parameters to a store Procedure

3. Insert into same table pulling one column from another table

4. Oracle Host Variables in Pro*C

5. insert data from one field in one table to another field in another table

6. Language Option

7. Inserting an entry into a table that has one attribute that's an identity column

8. Insert a new record in a table with just one column

9. Inserting into a one-column table with identity set

10. Really simple question: How to insert a table with only one column (also identity)

11. Insert into a table with only one identity column

12. one table - no dups in one column