Probably easy.....

  • hiya, im new to this sql scene..!

    i have an MS Access db containing a few tables of 'calls recorded' and 'finished calls'.

    (i want to move all 'Finished calls' to a seperate 'Finished Calls' table)

    anyway, the thing i want to do is to move records from Table1 to Table2, i am able to do this using the following code...

    SELECT * INTO Table2

    FROM Table1

    WHERE Finished='Yes';

    this code does work, however it does not delete the records that were moved out of Table1 - they are still there, its more or less copying and pasting them..

    any help would be much appreciated!

     

  • once you run that then run another sql statement

    DELETE * FROM Table1 WHERE Finished='Yes'

  • make sure you join with the new table then in order not to delete fresh finished records.

  • ok thanks guys..!

    ill try that now...but how do i run bot statements? do i need any seperators? and what do u mean by joining the two tables?

    sorry to sound silly!

  • first make copy (try to name the fields instead of using select *)

    SELECT * INTO Table2

    FROM Table1

    WHERE Finished='Yes'

    afterwards cleaning out table1

    the inner joins verifies you are only deleting "copied" records from table1

    (pk=name of primary key)

    DELETE Table1.PK

    FROM Table1 INNER JOIN Table2 ON Table1.PK = Table2.PK

    and table2.Finished=table1.finished

    WHERE Table1.Finished='Yes'

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply