Make sure the variable value isn't numeric and doesn't start with a number, (also, try using a named expression instead of the macro)
e.g.
startyrCol = "_"+Alltrim(Str(startyr))
alter table curheadscompare add column (startyrCol) n(8) null
>Hi all,
>
>I intend to add new fields to a cursor programatically, using a variable value as the field name. The value of the variable, of course, keeps on changing. My problem is that the code below does not read the value of the variable (startyr), and I get an error message.
>
>ALTER TABLE curheadscompare ADD COLUMN &startyr n(8) null
>
>Any solutions, anybody ?
>
>Thanks.
>
>Regards,
>
>Steve
Insanity: Doing the same thing over and over and expecting different results.