Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
scottichrosaviakosmos
Yak Posting Veteran
66 Posts |
Posted - 2010-12-19 : 09:45:45
|
i have 2 tables with one having some data with first table having id as primary key and auto incremented. secound table will have forign key to the id in 1st table.i am using a procedure where i am pass two values one is called @old and other @new.i will pass 2 values to my procedure. if i pass proc1 1,3 this means 1 is @old and 3 is @new value and by this the 1st table will populate equal rows with new id as it already has for the column prid which is second and main column for 1st table.table1:id prid add11 1 yahoo2 1 mark3 2 googletable2:id serid flag1 4 hello1 5 boss2 3 yyif execute my procedure passing values then :proc 1,4this means i am passing 1st value for old prid and 2nd one for new prid. so two new rows will be created with some new id since i have 2 rows for prid 1.so the new result of table1 will be :table1:id prid add11 1 yahoo2 1 mark3 2 google4 4 xyz5 4 abcand same will be updated in the table2 but since i have 2 id i.e id 1 and 2 for prid 1 and id 1 in table2 is more then one with some different data so the second parameter in the procedure was 4 which created new id and data in 1st table. i want the id's related to prid 4 to be inserted in table2 but with matching to the old prid i.e 1( as the first parameter in procedure). so here table 2 will have new values inserted as 4 and 5 but since id 1 which is related to the prid 1 of 1st table is repeated more then once so i want the new id 4 to be inserted twice but with serid and flag of id 1 in table2. AS below:table2:id serid flag1 4 hello1 5 boss2 3 yy4 4 hello4 5 boss scoo |
|
|
|
|