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!

Need help with code

Status
Not open for further replies.

joetrogdon

Technical User
Feb 20, 2004
4
0
0
US
Ok, I'm trying to copy fields from one dbf into another, but the below code is cutting, not copying

SELECT Inventor.sku, Inventor.item, Inventor.descrip,Inventor.price,Inventor.pricept1, Inventor.pricept2, Inventor.pricept3, Inventor.qty1, Inventor.qty2, Inventor.qty3, Inventor.orderqty, Inventor.weight, 000.0000
AS WIDTH;

FROM Inventor;
WHERE SKU = "BAGS" AND PRICE < .52 AND PRICE > .16

INTO TABLE intinv2.dbf

How would I get this to copy the data, not remove it from the first database? Thanks in advance.
 
Code is as follows:

SELE inventor
COPY FIELDS Inventor.sku, Inventor.item, inventor.descrip,Inventor.price,Inventor.pricept1, Inventor.pricept2, Inventor.pricept3, Inventor.qty1, Inventor.qty2, Inventor.qty3, Inventor.orderqty, Inventor.weight FOR SKU = "BAGS" AND PRICE < .52 AND PRICE > .16 TO intinv2.dbf

This creates a new table(or overwrites an existing table) called Intinv2. The second command is all on one line. You need not prefix the field name with "Inventor." if you SELE the source database as above.
 
These two approaches are different, but they both should work.

Cricket's approach using COPY TO will indeed COPY the records meeting the FOR... criteria into a different table named with the TO... portion of the command. It will automatically over-write if the SET SAFETY OFF is set, but will ask for over-write confirmation if SET SAFETY ON.

Your SELECT - SQL approach should also work. And it will not CUT records from the original table "inventor". Instead since you use the INTO TABLE... it creates a new table of only those records which meet the WHERE criteria. The original table is left totally intact and will "not remove it from the first database".

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Its simple way to copy field , use append commands

like this
use intinv2.dbf
appen from intinv1.dbf for SKU = "BAGS" AND PRICE < .52 AND PRICE > .16

try it

Giri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top