Skip to main content
May 2, 2010
Question

How can I Move data from one column to another in my access table?

  • May 2, 2010
  • 1 reply
  • 1503 views

I have two columns, one that stores current month’s data and one that stores last month’s data. Every month data from column 2 (this month’s data) needs to be moved to column 1 that holds last month’s data. I then null out column 2 so I can accumulates this month’s data.

I understand how to drop a column or add a column, how do I transfer data from one column to another.

Here is my trial code:

<cfquery name="qQueryChangeColumnName" datasource="#dsn#">

  ALTER TABLE leaderboard

  UPDATE leaderboard SET  points2 = points3

</cfquery>

Unfortunately, I get the following error:

Error Executing Database Query.

[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in ALTER TABLE statement.

How can I transfer my data with the alter table method?

    This topic has been closed for replies.

    1 reply

    Inspiring
    May 2, 2010

    how do I transfer data from one column to another.

    Since you are not modifying the table structure, the ALTER statement is not needed. All you need is the UPDATE statement.

    May 2, 2010

    With your comment in mind, I tried using the following:

    <cfquery name="qQueryChangeColumnName" datasource="#dsn#">
      UPDATE leaderboard SET  points2 = points3
    </cfquery>

    I am now getting the following:

    Too few parameters. Expected 1.

    Inspiring
    May 2, 2010

    I looked up the Access SQL reference (which is probably a good place to start when having issues with Access SQL), and it suggests you probably need a WHERE clause in there.

    http://office.microsoft.com/en-us/access/HA012315231033.aspx

    --

    Adam