>I have a challenge of copying some records from two tables of one database to the two tables (of the same name) in another database. Here is why it is a challenge.
>
>The table names are:
>PM_CATEG - Categories which has a PK field PMCATEG_PK
>PM_TASK - PM Tasks which has a PK TASK_NO (Identity) and PMCATEG_PK (set matching the PMCATEG_PK in PM_CATEG table).
>
>Example:
>
>PM_CATEG
>CATEGORY PMCATEG_PK
>PUMP 10
>
>PM_TASK
>PMCATEG_PK TASK DESCR TASK_NO
>10 List of items 200
>10 Another list 201
>10 Another list 280
>
>
>(Note that the TASK_NO is not always sequential because it could have been created at different time).
>
>Now I need to copy the records from PM_CATEG and PM_TASK of one DB to another for CATEGORY = 'PUMP'
>
>I would use the INSERT command but I have to dynamically INSERT into the PM_CATEG and then using a newly created PMCATEG_PK copy the PM_TASK.
>
>Is this possible or I am better off creating a VFP PRG to do it?
>
>TIA
There's a command called Set Identity_Insert that does the trick....
http://www.sqlteam.com/article/how-to-insert-values-into-an-identity-column-in-sql-server