Solved

SQL INSERT/APPEND Question

Posted on 2007-03-23
2
252 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

839 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