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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ALTER TABLE command

Status
Not open for further replies.

BlairB

Programmer
Joined
Dec 4, 2002
Messages
1
Location
CA
Hi,
I'm trying to add a field to a table, where the field is a variable. I keep getting a syntax error on the ALTER command line, because of the brackets no doubt, but I can't find the correct syntax and otherwise a field called "cName" is added:

PUBLIC cName AS char (20)
cName = xxx
SET PATH TO . . . \data
ALTER TABLE myTable ADD COLUMN (cName)

Any help greatly appreciated,
Cheers,
Blair
 
cName = 'FIELD2 C(10)'
ALTER TABLE myTable ADD COLUMN &cName

Make sure you add the field type and length etc
"I love work. I can sit and stare at it for hours..."
 
HI



PUBLIC cName AS char (20)
cName = xxx
SET PATH TO . . . \data
ALTER TABLE myTable ADD COLUMN (cName)


PUBLIC cName AS char (20) .. This is not correct..
PUBLIC cName
cName = SPACE(20)

However.. you dont have to do that way..

The correct code is...

ALTER TABLE myTable ADD Column cName C(20))

This is the correct syntax..

If you want a macro substitution Then..
myField = "cName"
ALTER TABLE myTable ADD COLUMN &myField C(20))

:-)




ramani :-)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Hi Ramani!

Why is the macro substitution the way I specified not the correct way of doing this? it works! Can you explain a bit please!

Thanks
Neil "I love work. I can sit and stare at it for hours..."
 
Hi Neil..

I think we have posted simultaneouly or atleast I got into without seeing your posting.. had my coffee and then completed.. Whatevr.. what you have posted is OK.

I only commented on BLAIRs macro name substitution with (cName) and any such macros.. Your macro is OK since it completes the statement with proper field requirements :-)

ramani :-)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Thanks Ramani, you had me worried there for a minute ;)

Neil "I love work. I can sit and stare at it for hours..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top