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

Create New Table from existing table

Status
Not open for further replies.

shangrilla

Programmer
Nov 21, 2001
360
US
Hi:

I need to create a new table that has the same structure as an existing table.

For eg: c:\myApp\SalesMan.dbf (this already exists)

I need to create c:\test\SalesMan.dbf (this should have the same structure as c:\myApp\SalesMan.dbf)

Thanks in advance
 
IF !USED('c:\myApp\SalesMan.dbf')
USER 'c:\myApp\SalesMan.dbf' IN 0
ENDIF
SELECT SalesMan

** This line copies structure and data
COPY TO c:\test\SalesMan.dbf

** This line copies structure only
COPY STRUCTURE TO c:\test\SalesMan.dbf
 
Sorry, typo in 2 line of code:
IF !USED('c:\myApp\SalesMan.dbf')
USE 'c:\myApp\SalesMan.dbf' IN 0
ENDIF
 
Take 3, Sorry, typo in 2 line of code:
IF !USED('c:\myApp\SalesMan.dbf')
USE c:\myApp\SalesMan.dbf IN 0
ENDIF
 
********************************************
* Create with Same Structure - No Data


SELECT 0
USE c:\myApp\SalesMan NOUPDATE
=AFIELDS(arTemp)
CREATE TABLE c:\test\SalesMan FROM ARRAY arTemp
RELEASE arTemp

**Note you can also create cursors this way if your test **table is for a temporary purpose
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top