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!

Simple (I think) create table question

Status
Not open for further replies.

shmmeee

Programmer
Apr 17, 2001
104
GB
I've never used FoxPro before, but have to now for a uni assignment. I need to create some tables, using SQL statements, that contain (among other things) fields such as:-
HorseDOB (DD/MM/YYYY)
Odds (4-1, 5-4 etc)
SexOfHorse (M/F)
Result (either 1,2,3,4,U or N)
TimeofRace (HH:MM)
and Winnings (£x,xxx) (could possibly be just a number)

I think I'm right in saying date is as simple as "HorseDOB D" (in the create table command) can anyone help me with the others? or even better point me at some kind of SQL in FoxPro 2.x user guide?

TIA,
Iain
 
In Fox 2.x online help, click Search and look for CREATE TABLE. It will tell you the syntax for the different field types.

The basics are like this though:

CREATE TABLE Horses ;
(HorseDOB D(8) ,;
Odds C(10) ,;
SexOfHorse C(1) ,;
Result C(1) ,;
TimeofRace C(5) ,;
Winnings N(10))

C = Character
N = Numeric
D = Date
() = how wide data field is

Dave S.
 
You have indicated the need to "to create some tables, using SQL statements". Unfortunately the two items (Create Tables & SQL statement usage) are mutually exclusive for this task.

As DSummZZZ has shown, Foxpro has its own method of creating data tables. This method does not use SQL statements.

However, if you already have a table (reftable.dbf) which already contains the appropriate field types and field lengths it can be referenced by the SQL statements. You can then "clone" the field types into a new table and rename the fields.

SELECT reftable.datefld AS HorseDOB,;
reftable.charfld AS Odds,;
reftable.numfld AS Winnings;
FROM reftable;
INTO TABLE newtable

You can manipulate the SQL statement as needed.

Good Luck,
jrbbldr
jrbbldr@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top