Rename mdb column

StewartBW 1,145 Reputation points
2024-05-17T23:55:41.8966667+00:00

Hello

I use Access Database Engine and OleDbReader to work with mdb and accdb files, need to rename a column:

"ALTER TABLE xc RENAME Column old new LONG"

Searched and found ADE might not support it, what if I add a new column and drop the old one?

But the new one will be added to end of tables, need to be in the place of old one.

Anyway using ADE?

Thanks

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,011 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,737 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 32,376 Reputation points Microsoft Vendor
    2024-05-20T01:28:16.28+00:00

    Hi @StewartBW ,

    The SQL syntax ALTER TABLE xc RENAME COLUMN old TO new is not supported directly by Access SQL.

    If the column order is crucial for your application, and you absolutely need the new column to be in the same position as the old one, you'll need to:

    1. Create a new table with the desired column order.
    2. Copy the data from the old table to the new table.
    3. Drop the old table.
    4. Rename the new table to the original table name.

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.