Alter tables via code

B

Bob

HI there,

I need to be able to add a new field to my table and
change the data types of certain fields by using code.

Any Ideas?
 
A

Allen Browne

These examples show how to use a DDL query statement to:
- change the size of a field;
- change the data type of a field;
- add a new field to a table;
- remove a field from a table:

ALTER TABLE MyTable ALTER COLUMN MyText2Change TEXT(100);
ALTER TABLE MyTable ALTER COLUMN MyField DOUBLE;
ALTER TABLE MyTable ADD COLUMN SomeNewField TEXT(60);
ALTER TABLE MyTable DROP COLUMN SomeNewField;

You can execute a string using DAO
dbEngine(0)(0).Execute strSQL
or ADO:
CurrentProject.Connection.Execute strSql
 

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