Solved

SQL INSERT/APPEND Question

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql query help 15 55
Sql server Error message 3 16
Delete old Sharepoint backups 2 22
SQL - Ordering Supervisor Hierarchy 2 14
I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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.
Viewers will learn how the fundamental information of how to create a table.

726 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