|
Home > Archive > FoxPro Help and Support > December 2005 > copy structure
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi
I have two table and the name of them are A,B both of them contain 100 record
And table A has a compound index .and table B don’t has index.
I want copy stracture of table A (compound index) to table B what must I do.
Thank you
| |
| Josh Assing 2005-12-10, 11:24 am |
|
Just create the indexes.
if you need to do it programatically there's two ways.
one is to look at the existing indexes of A and create them with b. Look at
tag(), key(), etc.
The other is temporarily delete table B -- something like:
use B
copy to C
use
delete file b.dbf
use A
copy stru with cdx to B
use B
appe from C
delete file c.dbf
While this will work fine for 100 records, if you've got thousands, that will be
slow.
On Fri, 9 Dec 2005 23:19:01 -0800, "bijan" <bijan@discussions.microsoft.com>
wrote:
>Hi
>I have two table and the name of them are A,B both of them contain 100 record
>And table A has a compound index .and table B don’t has index.
>I want copy stracture of table A (compound index) to table B what must I do.
>Thank you
--- AntiSpam/harvest ---
Remove X's to send email to me.
| |
| Alan Sheffield 2005-12-12, 8:26 pm |
| Manual solution.
using windows make a copy of a.cdx named b.cdx
In VFP
use b index b.cdx excl
reindex
If you need to automate it.
Option 1(If you only need the indexes):
*===================
====================
use a in 0
use b in 0
select b
x=1
do while not empty(key(x,[a]))
lcKey = key(x,[a])
lcOrder = Order(x,[a])
lcFor = for(x,[a])
if not empty(lcFor)
lcFor = [For ]+lcFor
endif
index on &lcKey. tag &lcOrder. &lcFor.
x=x+1
enddo
*===================
====================
Option2 (need the structure and indexes)
*===================
====================
use a in 0
use b in 0
select a
copy structure to tempfile with production
select b
copy to backup_b with production
close databases all
use tempfile
append from b
copy to b with production
*===================
====================
I hope that helps
Alan
"bijan" <bijan@discussions.microsoft.com> wrote in message
news:EBC5C97D-4241-4EB2-BADA- CAB65E4607E9@microso
ft.com...
> Hi
> I have two table and the name of them are A,B both of them contain 100
> record
> And table A has a compound index .and table B don't has index.
> I want copy stracture of table A (compound index) to table B what must I
> do.
> Thank you
>
>
|
|
|
|
|