Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL INSERT/APPEND Question

Posted on 2007-03-23
2
Medium Priority
?
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 9

Accepted Solution

by:
dbeneit earned 200 total points
ID: 18783987
insert into table1 (col1,col2,col3)
select col1,col2,col3 from table2
0
 
LVL 9

Assisted Solution

by:dbeneit
dbeneit earned 200 total points
ID: 18783998
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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

610 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