Solved

SQL INSERT/APPEND Question

Posted on 2007-03-23
2
234 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
ID: 18783987
insert into table1 (col1,col2,col3)
select col1,col2,col3 from table2
0
 
LVL 9

Assisted Solution

by:dbeneit
dbeneit earned 50 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
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.

947 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

19 Experts available now in Live!

Get 1:1 Help Now