Results 1 to 2 of 2

Thread: adding a new field to an accessdb

  1. #1
    Join Date
    Mar 2003
    Posts
    3

    adding a new field to an accessdb

    Hi,

    I have this problem: I'm creating a weblinked dbase using Access and ASP. The problem is that the fields of the table won't be always the same. E.g. sometimes there will be need for an extra field, but after a while it may not be necessary anymore.

    I don't think it is possible to use sql to add a field to an accessdbase or is it? How else can I solve this problem?

    thanks for your reply,
    yours sincerely,
    Dimitri De Vos

  2. #2
    Join Date
    Mar 2003
    Location
    Jacksonville, Florida
    Posts
    52
    the sql code to alter a table is

    add a field:

    ALTER TABLE table_name
    ADD new_field type other_options


    delete a field:

    ALTER TABLE table_name
    DROP old_field


    change field:

    ALTER TABLE table_name
    ALTER COLUMN cur_field type other_options


    FULL STATEMENT TO ADD FIELD TO EXISTING TABLE:

    ALTER TABLE tbl_main
    ADD new_field int NULL
    DEFAULT 1 WITH VALUES

    This does a couple things...

    Adds the new field.
    Default value is 1 for this field if unspecified.
    May be NULL.
    **WITH VALUES makes all existing value take on the default value instead of using NULL**
    If WITH VALUES was not specified, the existing records would have NULL in the new field.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •