Link to home
Start Free TrialLog in
Avatar of sqlagent007
sqlagent007Flag for United States of America

asked on

copy table1 and create table2, query table1 for changes and add them to table2

I am copying data from table1 to create table2. I would like to create table2, do testing then append current data from table1 into table2.

Can anyone help me write a query that takes all data from table1 that is not in table2 and inserts the data in table2?

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of Member_2_2484401
Member_2_2484401
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
INsert table2
Select *
from table1 as one left outer join table2 as two
on one.id = two.id
where two.id is null
Avatar of r_a_j_e_s_h
r_a_j_e_s_h

u can use DTS to trnsfer the data, which will be very useful and gives knowledge in DTS
You can do this with or without DTS.  Its not really needed.
Using DaveSlash example,

insert into employee2
select * from employee
minus
select * from employee2;

insert into employee2
select * from employee
minus
select * from employee2;


That won't work if this is SQL Server...not sure what platform this is.....MINUS does not exist in T-SQL