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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging databases

Status
Not open for further replies.

AdaHacker

Programmer
Sep 6, 2001
392
US
Okay, I know zero about FoxPro, and yet I'm stuck maintaining this old FoxPro 2.5 program. I have an idea of what needs to be done, but no clue how to go about it.

What I need to do is to take several different FoxPro 2.5 database files and merge them into a single database file. They all have the same layout, I just need to get all the records into one file. This is something that will be done on a regular basis, so it needs to be automated in the program, or else I would have just done it in another language.

I couldn't think of a way to do this in just SQL, and I don't even know where to start in FoxPro. Can anyone give me some ideas?
 
Adahacker:
Piece of cake. If they all have the same structure & field size do the following (and if not, just modify them first to match field names & sizes to the biggest size):

First, select any table into a work area by:
Note: Do each of these steps from a command window, don't try to run this as a single piece of code...


USE <path\tablename> IN 0
*
* then make a blank one
*
COPY STRUCTURE TO ALLDATA
*
* where ALLDATA is the name of the new table you have
* just created, to put everything in.
USE ALLDATA IN 0
SELECT ALLDATA

* Then one by one, do the following for each table:
APPEND FROM <path\tablename>

(example:
APPEND FROM DBFS\CUST1.DBF
APPEND FROM DBFS\CUST2.DBF
APPEND FROM DBFS\CUST3.DBF
etc, etc.

Once you have &quot;APPENDED FROM&quot; each of the tables you want to add, you will have one giant &quot;ALLDATA&quot; data table. Have fun!

Thanks,
-Scott

Please let me know if this has helped! s-)
 
Hi
If you want to use SQL

SELECT * FROM myTable1 INTO DBF AllData ;
UNION ALL SELECT * FROM myTable2 ;
UNION ALL SELECT * FROM myTable3
etc...

Hope you get the idea..
If for any reason, the number of files are more and the UNION cannot continue, since the length i stoo long, then.. use intermediary file ALLDATA1 and then use that as the first file and continue to add other files.
Hope this helps :)
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Thanks guys, that helped a lot. Hopefully I should be able to get the program working now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top