Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add column to a table programmatically
Message
From
20/10/2005 00:54:05
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
20/10/2005 00:34:00
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01060607
Message ID:
01060610
Views:
7
>hi, i want to add a column to a table during program run time. the name of the column will be input by user into a text box and be used as the name of the column. so the name is a variable and dynamic depending on what is being keyed in. how can i tell the system that the column name is a variable. i tried the following command but a syntax error message popup:
>
>ALTER TABLE ADD COLUMN varname C(20)
>
>thanks

You can use a name expression (parentheses):
myvar = "Column1"
alter table abc add column (MyVar) N(2)
Or a macro substitution:
myvar = "Column1"
alter table abc add column &MyVar N(2)
The first alternative is faster in most cases, so it should be preferred. The second offers you access to some features that are not available if you use only name expressions - you can substitute entire commands.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform