Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with copying a table

Status
Not open for further replies.

donafran

Programmer
Jul 11, 2002
71
0
0
US
Hello !
Here is our problem - we have 2 tables - Table A and Table B - which are IDENTICAL except for 2 fields at the end of Table B.

What I want to do is COPY the data for all the common fields from Table A into Table B, leaving the 2 extra fields on the Table with a value of NULL or blank.

Then, later, I can run a job to populate the extra fields.
We are willing to use UPDATE, INSERT or any other command !!
Thanks
 
assuming TableA has fields f1, f2, f3, f4 and TableB has fields f1, f2, f3, f4, f5, f6:
Code:
insert into TableB (f1, f2, f3, f4)
    select f2, f2, f3, f4 from TableA
if i understand correctly, you want to copy ALL the date from TableA into TableB?
in that case the insert statement above should be okay.

hope this helps
 
insert into TableB (f1, f2, f3, f4)
select f2, f2, f3, f4, NULL, NULL from TableA

You can directly select Values like NULL in this case.

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
Or...
Code:
insert into tableB
select *, null,null from tableA

Gauss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top