Solved

SQL INSERT/APPEND Question

Posted on 2007-03-23
2
224 Views
Last Modified: 2012-05-05
SQL Question:

How would you append to an existing table using ALL of the values from a table?  As example:  
Table A has (col1,col2,col3).
Table B has (col1,col2,col3) with 50 records.  

How would you take all 50 records from Table B and append them to Table A (assuming the data types and lengths are the same)?

DATABASE SYSTEM:  SQL Server 2000

0
Comment
Question by:irishm20
  • 2
2 Comments
 
LVL 9

Accepted Solution

by:
dbeneit earned 50 total points
Comment Utility
insert into table1 (col1,col2,col3)
select col1,col2,col3 from table2
0
 
LVL 9

Assisted Solution

by:dbeneit
dbeneit earned 50 total points
Comment Utility
if some record of table2 can be duplicated in table 1 then
insert into table1 (col1,col2,col3)
select t2.col1,t2.col2,t2.col3 from table2 t2 left join table1 t1 on t1.col1=t2.col1 and  t1.col2=t2.col2 and  t1.col3=t2.col3 where t1.col1 is null
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now