Sh M
asked on
SQL Query - sql 2005/2008 - data migration
Hi,
Having the following tables:
tableA
column: A_IDPK, ADesc, A_X,B_ID(FK)
tableB:
column: B_ID, BDesc
TableC
column: C_IDPK, BDesc, C_A_X, B_ID(FK),AutoIDoFA
TableA is already populated, table B is already populated.
I can use the source table to populate tableC.
The column A_X is unique identifier for table A, it also matches with C_A_X in tableC.
The source table already has a column matching C_A_X. so there is no problem to populate
this column when migrating data to tableA.
I like to write a query to update the value of C_X with
what I need to do is to actually find the relevant A_IDPK of A_X and also put that number into tabeC.AutoIDoFA.
how can this be done.
Thanks in advance
Having the following tables:
tableA
column: A_IDPK, ADesc, A_X,B_ID(FK)
tableB:
column: B_ID, BDesc
TableC
column: C_IDPK, BDesc, C_A_X, B_ID(FK),AutoIDoFA
TableA is already populated, table B is already populated.
I can use the source table to populate tableC.
The column A_X is unique identifier for table A, it also matches with C_A_X in tableC.
The source table already has a column matching C_A_X. so there is no problem to populate
this column when migrating data to tableA.
I like to write a query to update the value of C_X with
what I need to do is to actually find the relevant A_IDPK of A_X and also put that number into tabeC.AutoIDoFA.
how can this be done.
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tanks
UPDATE tableA,TableC SET TableC.AutoIDoFA=tableA.A_
That should match records between tableA and TableC, where A_X=C_A_X, and put the identity PK of table A into the AutoIDoFA field of TableC.