Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 adding several rows to a table at once?

Author  Topic 

MCCCLXXXV
Starting Member

10 Posts

Posted - 2009-05-26 : 13:17:03
Hi,

I'm still new to SQL and I can't seem to find out how to do this anywhere. How do I add several rows of data to an already existing table?

For example, if my PeopleOLD table currently looks like this:


ID Last First
43 Harris Jackie
55 Harris John
88 Harris Emily


and my PeopleNEW table looks like this:

ID Last First
32 Smith May
64 Smith Sam
35 Smith Joe


What code do I need to make PeopleOLD look like this?:

ID Last First
43 Harris Jackie
55 Harris John
88 Harris Emily
32 Smith May
64 Smith Sam
35 Smith Joe



Thanks for your help.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-26 : 13:34:44
insert peopleold (id, last, first)
select id, last, first from peoplenew


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-26 : 13:35:12
[code]
INSERT INTO PeopleOLD (ID , Last, First)
SELECT ID , Last , First
FROM PeopleNEW
[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-26 : 13:35:35
Go to Top of Page

MCCCLXXXV
Starting Member

10 Posts

Posted - 2009-05-26 : 13:55:08
haha I knew it would be ridiculously easy. thanks.
Go to Top of Page
   

- Advertisement -