Jun 18, 2004 #1 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
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
Jun 18, 2004 1 #2 rgbean Programmer Nov 9, 2000 5,707 US 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 Upvote 0 Downvote
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
Jun 18, 2004 #3 DSummZZZ Programmer Oct 24, 2000 4,250 US You may also need to change this line: field_name = "col" + str(x) -to- field_name = "col" + ALLTRIM(str(x)) -Dave Summers- Even more Fox stuff at: http://www.davesummers.net/foxprolinks.htm Upvote 0 Downvote
You may also need to change this line: field_name = "col" + str(x) -to- field_name = "col" + ALLTRIM(str(x)) -Dave Summers- Even more Fox stuff at: http://www.davesummers.net/foxprolinks.htm
Jun 18, 2004 1 #4 GriffMG Programmer Mar 4, 2002 6,343 FR 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 Upvote 0 Downvote
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
Jun 18, 2004 #5 rgbean Programmer Nov 9, 2000 5,707 US Griff, So practical! I figured this was a one shot situation and simplicity was the key. Rick Upvote 0 Downvote
Jun 18, 2004 #6 GriffMG Programmer Mar 4, 2002 6,343 FR Sorry, Rick - I'm too geeky for my own good! Regards Griff Keep [Smile]ing Upvote 0 Downvote