Results 1 to 3 of 3

Thread: reordering?

  1. #1

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727

    reordering?

    dear gurus,

    i'm adding a column to an access database using this code:
    VB Code:
    1. Conn.Open StrConnect
    2.     'add fields
    3.     SqlExec = "ALTER TABLE newsletters_entries ADD COLUMN Company VARCHAR(200);"
    4.     Conn.Execute SqlExec
    5.     'close
    6.     Conn.Close
    and that works fine. however, this add this new column at the END of the database. is there any way to actually add it into a specified place?

    thank you,

    wc.
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: reordering?

    I found this somewhere on the Internet. It suggests that you can use AFTER to specify where you want the column added.

    Code:
    ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...]
    
    alter_specification:
            ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
      or    ADD [COLUMN] (create_definition, create_definition,...)
      or    ADD INDEX [index_name] (index_col_name,...)
      or    ADD PRIMARY KEY (index_col_name,...)
      or    ADD UNIQUE [index_name] (index_col_name,...)
      or    ADD FULLTEXT [index_name] (index_col_name,...)
      or	ADD [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
                [reference_definition]
      or    ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
      or    CHANGE [COLUMN] old_col_name create_definition
                   [FIRST | AFTER column_name]
      or    MODIFY [COLUMN] create_definition [FIRST | AFTER column_name]
      or    DROP [COLUMN] col_name
      or    DROP PRIMARY KEY
      or    DROP INDEX index_name
      or    DISABLE KEYS
      or    ENABLE KEYS
      or    RENAME [TO] new_tbl_name
      or    ORDER BY col
      or    table_options
    This world is not my home. I'm just passing through.

  3. #3

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727

    Re: reordering?

    thank you,

    i'm actually using:
    VB Code:
    1. "ALTER TABLE newsletters_entries MODIFY COLUMN [Company] AFTER [Last Name];"
    but this is not working. do you know if this is SQL only or access is enough?...
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

Posting Permissions

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



Click Here to Expand Forum to Full Width