none
Creating a joint multiple key table in access database RRS feed

  • Question

  • I have a table in a database that i want to transfer to another database. The tricky thing is that i only want to transfer some fields in that table(eg. field1,field2,field3 but not field4). Also i want the new table to have a primary key made up of multiple fields. The table structure is :

     

    TABLE1{ num1 as int,num2 as int, field1 as text, field2 as text, field3 as text} transfered to NEWTB{num1,num2, field1,field2}

     

    if possible i want to do it only in sql or in vb code.

     

     

    Monday, June 11, 2007 3:22 PM

All replies

  • I believe you could use INSERT... SELECT SQL statement like

     

    INSERT INTO NEWTB SELECT ...... FROM TABLE1

     

    But if NEWTB does not exists and you need to create it on insert of the records, then you could use SELECT INTO SQL statement, like

     

    SELECT ....   INTO NEWTB FROM TABLE1

     

     

    Tuesday, June 12, 2007 10:34 AM
    Moderator

  • In addition to what Val mentioned you can create your primary key using SQL DDL:

    Fundamental Microsoft Jet SQL for Access 2000

     

     

    Tuesday, June 12, 2007 1:05 PM