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

Copying DBF structure with properties

Status
Not open for further replies.

mikemck7

Technical User
Dec 17, 2003
38
Hi,

I have a table in a VFP database with numerous fields. The table is well documented with comments. I wish to build a second table that is a duplicate of the first such that only the table name changes. I especially want to preserve the index expressions and field comments. What is the easiest way to accomplish this?

Mike

 
Mike,

I had a similar problem a couple of weeks ago -- see thread1252-1410361

In your case, since you want to create a second copy of the table (rather than renaming it, which is what wanted to do), the best solution might be COPY STRUCTURE EXTENDED. But you would still need to reindex.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 

mikemck7,

In addition to what Mike Lewis said, I can suggest that you use KEY() or SYS(14) function to return your index expressions, and TAG() function to return the tag names.

You can loop with a counter that you use as an index number until you get EMPTY(KEY()) or EMPTY(TAG()), and either index your new table right away on each of them, or save them to anothe table/array, and then index your new table using expressions from it.
 
An Idea comes to mind...may or may not work;

use gendbc.prg to generate the code for the whole Dbc. Next open the code generated, delete everything except the code to create the table you want to duplicate, change the name then run it. It should create the table.

Make sure you change the code that creates the dbc. by changing it to open and set the dbc.
 

The gendbc.prg approach works just fine. Had my new duplicate table built in just a few minutes, indexes relations and all. Thanks.

Mike M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top