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

COPY TO question 1

Status
Not open for further replies.

July Derek

Programmer
Aug 21, 2022
5
0
0
IN
Hi All,


I'm trying to copy a Table along with all the records to another identical table with another name.

SELECT einvoice

COPY TO temp

This command only copies the einvoice Table structure to the TEMP table. No records are being copied.

I tried COPY ALL TO temp still no records are being copied.

Thanks in advance !


 
COPY TO should copy all the records along with the structure. Are you sure you are looking at the right table? Is there perhaps another table named Temp in another directory?

The only other explanation I can think of is that a filter was in force on eInvoices, and all the records were out-filtered (and/or deleted).

Instead of COPY TO, you could try COPY FILE (but in that case you would need to copy any index and memo files separately).

Alternative, you could do this:
[tt]
SELECT * FROM eInvoices INTO TABLE temp[/tt]

but you would again have to recreate the indexes.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I might be reading this wrong but if you have an identical table with a different name, can you not use:

Code:
Use MYINDENTICALTABLE shared
Append from einvoice

Or if you are just copying then whole einvoice table with data to another table with an identical structure, what about:

Code:
Copy file [b]EINVOICE[/b] to MYINDENTICALTABLE with CDX && (If you have a CDX)

I might be wrong but thought I would throw in my limited knowledge.

Good luck


Thank you

Steve Williams
VFP9, SP2, Windows 10
 
You mix up COPY TO and COPY FILE, but WITH CDX is only an option of COPY TO, COPY FILE is straight forward just copying a file, not a file pair or triplet and not only a table.

Also, Mike is right that a filter applies to COPY TO, it only copies records fulfilling the filter condition, if one is set, and only undeleted rows, also when you have deleted off and don't use any FOR condition.

Chriss
 
Mike Lewis said:
COPY TO should copy all the records along with the structure. Are you sure you are looking at the right table? Is there perhaps another table named Temp in another directory?

The only other explanation I can think of is that a filter was in force on eInvoices, and all the records were out-filtered (and/or deleted).

Instead of COPY TO, you could try COPY FILE (but in that case you would need to copy any index and memo files separately).

Alternative, you could do this:

SELECT * FROM eInvoices INTO TABLE temp

but you would again have to recreate the indexes.

Mike

Thanks Mike. You were right. There was another instance of TEMP in the Load event of the Form. I was modifying it to another and had forgotten that. Was breaking my head over this for over an hour.

Thanks to all for your replies. Most appreciated !
 
Glad to hear the problem is solved, July Derek, and thanks for letting us know. This perhaps highlights the danger of using common, non-meaningful names like Temp for cursors or other objects.

Welcome to the forum, by the way.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top