Create column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the code to create a new column to an existing table. I don't want to
manually create a column in the design view, I want the create or update
statement.
 
Yes, it is possible. Just use a Data Definition Query

- Create a new query, but don't add any tables.
- On the Menu Bar, select Query | SQL Specific | Data Definition
- Write your query to modify the table, using the ALTER TABLE syntax.

For example: "ALTER TABLE Tablename ADD COLUMN NewField TEXT(25);"

For more information about writing an ALTER TABLE query, search Help.

You could also use DAO or ADO to do this programmatically:
ACC2000: How to Use DAO to Programmatically Add an AutoNumber Field to a Table
http://support.microsoft.com/default.aspx?scid=kb;en-us;210405

If you do some digging in the MS Knowledge Base or in other sources you
should be able to find some examples for doing this in ADO.

Hope that helps!

DBS (David Staas)
 
What is the code to create a new column to an existing table. I don't want to
manually create a column in the design view, I want the create or update
statement.

ALTER TABLE tablename
ADD COLUMN newcolumname
datatype(size);

where datatype is YESNO, COUNTER, CURRENCY, DATETIME, SHORT, LONG,
SINGLE, DOUBLE, TEXT, MEMO, or OLEOBJECT and Size is the optional size
of a Text field.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

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

Back
Top