When export/import table, the primary keys are not kept.

  • When export/import table from one database to another, the primary keys are not kept.  Any suggestions?  Thanks

  • I assume you're using the wizard.  Are you dropping and creating the destination table each time?  Can you post the table schema indicating the primary key?

    Greg

    Greg

  • Yes, I am using the wizard.  Initially, the target table does not exits.

    Once the target table is created, I delete the records and add the keys.

    Then I use the wizard again to append records to the target table.

    I do not know what you mean "post the table schema"?

  • Best way create the table before hand. Create all your keys and use the wizard to copy.

    If the tables in both databases are the same. Script the one table then run the sql in the query analyzer for the other databse

  • So, are you saying that when you import the data, the primary key contraint goes away or the values for the columns that make up the primary key aren't imported?

    By schema, I mean the layout of the table, including column data types and which columns make up the primary key.

    Greg

     

    Greg

  • Sorry to introduce my opinion.

    If you want you can use in the Dialog Box with name "Specify Table Copy or Query"  - Copy objects and data between SQL Server Database. There you can create a tables with a primary key, procedures, triggers and so on.


    Vinicius B Cobra Vivas

  • When running the wizard to create the target table, the primary key contraint goes away.

    In the prompt "Specify Table Copy or Query", three options are available:

    1. Copy Tables and views from source database

    2. Use a query to specify  the data to transfer

    3. Copy objects and data between databases

     

    Currently, I use option 1, which the primary key contraint is dropped.

    So I should be using option 3 instead?

  • Yes if you use option 3 the keys will be transfered with the data- just make sure the option is checked.

Viewing 8 posts - 1 through 7 (of 7 total)

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