Question : replace value and reference in multiple tables

what would be the simplest logic you would use to accomplish the following:

tableMatch is the matching table, it gives the new values for an old value that must be replaced with a logic in 4 following tables. The steps involved are:
*insert another record into tableA with a new PK and replace the new value, and copy the rest of the data.
*do the same concept with tableB also
*insert another records in tableC with a new PK, and get the new PK from tableB and keep as FK and get the rest of the values
*the only key in tableD is tableC_FK, so just insert a new record with the new tableC_PK reference and get the new value there also and get the rest of the data..

Assume, there will be 1000s of records like this that the logic has to run against....
thanks
------------------------------------

tableMatch - OldVal,NewVal
12234,94223

tableA - PK,'values'
A1,12234,1,2,3
      
tableB - PK,tableA_FK,'values'
B1,12234,4,5,6

tableC - PK, tableB_FK,'values'
C1,B1,7,8,9

tableD - tableC_PK,'values'
C1,12234,11,12
----------------
After the DMLs
tableMatch - OldVal,NewVal
12234,94223

tableA - PK,'values'
A1,12234,1,2,3
A2,94223,1,2,3
      
tableB - PK,tableA_FK,'values'
B1,12234,4,5,6
B2,94223,4,5,6

tableC - PK, tableB_FK,'values'
C1,B1,7,8,9
C2,B2,7,8,9

tableD - tableC_PK,'values'
C1,12234,11,12
C2,94223,11,12

Answer : replace value and reference in multiple tables

can you create\use Foreign Keys
on UPDATE CASCADE?

The Importance of SQL Server Foreign Keys

http://www.mssqltips.com/tip.asp?tip=1296

Random Solutions  
 
programming4us programming4us