Wiki Home

Using AVariable To Name Columns In Alter Table Command

Namespace: VFP
Does anyone know how to use a variable to name columns in a table using the alter table? VFP7 doesn't seem to be recognizing the variable as a variable and the 2nd time thru attempts to name the next column the same as the first. I tried using an array to do this too with no success.

CREATE TABLE tablename ;
(field_1 c(60))
FOR x = 2 TO (num_fields)
colhead = "field_" + ALLTRIM(STR(x))
ALTER TABLE tablename add COLUMN (m.colhead) c(60)

Use name expression as shown. Also Wikis is more for discussions and not questions.
Category Questions

Wiki is not for Questions?!
There are no requests by the operator of this wiki to limit questions on this site. To all: Please ask away, most of us would like to help if we can.

I meant, not for simple questions which can be answered right away. It is more of a discussion board.

Ben Creighton
( Topic last updated: 2007.05.11 04:58:04 PM )