You are here:

FoxPro/in FOXPRO, how to combine many DBF's of the same structure to one table/query

Advertisement


Question
sir,
i am learning foxprox (v2.6, for DOS), and i would like to combine 100 or more database (.DBF) files of having exactly the same field structures into one table or query. i tried QUERY but didnt came up. expect your answer at your convenience. this is for a project work that i am doing.

Answer
I will answer if you promise to never call me "sir" again, because I am not a man.

Since you have that many database files, it would be best to do this with a program, rather than at the command window.

Select one database as your main file, which all records of the others will be appended into. Place all of the other ones into their own directory. This directory should hold only those other databases, no other files.

USE mainfile
SET DEFAULT TO <pathAndDirectory>
=ADIR(laDBFs,'*.dbf')
FOR lnDBFcnt = 1 TO ALEN(laDBFs,1)
  lcDBFname = laDBFs[lnDBFcnt,1]
  APPEND FROM &lcDBFname
ENDFOR
RETURN  

FoxPro

All Answers


Answers by Expert:


Ask Experts

Volunteer


Martha Granger

Expertise

Can help with all areas (general, programming, report writing) of Foxpro for Windows or DOS. (Non-Visual versions)

Experience

Computer consultant and analyst with over 15 years experience working with Foxbase and then Foxpro.

©2012 About.com, a part of The New York Times Company. All rights reserved.