Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verify if a field already exists in a table
Message
From
07/07/2007 10:42:09
 
 
To
06/07/2007 12:35:21
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01238247
Message ID:
01238380
Views:
30
>>How can I verify if a field already exists in a table?...
>>Need to create it if doens´t....

>
>If it does not exist, add it
>
>If Fsize("MyField") = 0
>   Alter Table MyTable Add Column MyField C(10)
>EndIf
>
>
>Another:
>
>If it does exist, drop it
>
>If Fsize("MyField") > 0
>   Alter Table MyTable Drop Column MyField
>EndIf
>
>Exclusive of course.


But make sure SET COMPATIBLE is OFF; otherwise FSIZE() has an entirely different meaning.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform