Alter tables via code

  • Thread starter Thread starter Bob
  • Start date Start date
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?
 
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
 
Back
Top