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

Add 100 fields to an existing table 2

Status
Not open for further replies.

RussA

Programmer
Mar 19, 2003
27
US
I would like to add 100 fields to an existing table, what do I need to change to make this work? Thanks in advance Russ.

For x = 1 to 100
field_name = "col" + str(x)
Alter TABLE table_name ADD COLUMN field_name n(10,2) NULL
Next x

 
Russ,
Close - just change the one line to:
Code:
Alter TABLE table_name ADD COLUMN [b][red]&[/red][/b]field_name n(10,2) NULL
Rick
 
The code is good, but would be VERY inefficient if the existing table is large.

If it is, I would suggest that you create a new table with the desired structure and append the data to it.

Or copy the contents to a temp table, zap the existing one then pull the data back.


HTH

Regards

Griff
Keep [Smile]ing
 
Griff,
So practical! I figured this was a one shot situation and simplicity was the key.

Rick
 
Sorry, Rick - I'm too geeky for my own good!

Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top