Adding 2 fields in a table

J

jeanulrich00

Hi

I am trying to add 2 fields in a table using SQL Statement

Right now I am using the following code without any problem.

ALTER TABLE [T-PeriodesTempo] ADD [PeriodNo] COUNTER

And this code add a column (field) named PeriodNo and it is perfect

But I cannot find the syntax to add 2 columns (fields) at the same
time.

I have try many different script and all the time an error message pop
telling that I have the wrong syntax.

Last one I have try (I found it on internet) is

ALTER TABLE table_name
ADD ( column_1 column-definition,
column_2 column-definition );

but it is not working

I need to add an autonumber field and a text field

The first field to add is a Counter and I have succeed. Second field
I am trying to add is a text field with 3 character.

Thanks for helping
 
F

fredg

Hi

I am trying to add 2 fields in a table using SQL Statement

Right now I am using the following code without any problem.

ALTER TABLE [T-PeriodesTempo] ADD [PeriodNo] COUNTER

And this code add a column (field) named PeriodNo and it is perfect

But I cannot find the syntax to add 2 columns (fields) at the same
time.

I have try many different script and all the time an error message pop
telling that I have the wrong syntax.

Last one I have try (I found it on internet) is

ALTER TABLE table_name
ADD ( column_1 column-definition,
column_2 column-definition );

but it is not working

I need to add an autonumber field and a text field

The first field to add is a Counter and I have succeed. Second field
I am trying to add is a text field with 3 character.

Thanks for helping

From Help on SQL + Data Definition Language + Alter Table:

**You cannot add or delete more than one field or index at a time. **

The following works for me:

Dim strSQL As String
strSQL = "Alter Table MyTable Add Column PeriodNo Counter"
CurrentDb.Execute strSQL, dbFailOnError
strSQL = "Alter Table MyTable Add Column Notes Text(3)"
CurrentDb.Execute strSQL, dbFailOnError
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top