
As you can see, I have got 2 tables here, table 1 and table 2. The column srid in Table 1 is an identity column.
Table 2 is like a child table of table 1, where we can link table 2 with table 1 by using srid column.
Now what I would like to achieve is to sort of replace the original srid, i.e. 1,2,3 with the new ones, i.e. 4,5,6, while in the mean time we keep its original crvalue unchanged. And then we will insert it back into table 2.
I find replacing new srids is a bit challenging and get stuck. So what query/script should I write to achieve this?
Thanks.
You could try something like this:
Basically, you are ranking
sridvalues within eachuidgroup and then joining the two subsets by the ranks to associate every oldsridwith a new one. Naturally, you are joiningTable2with the oldsridsubset too, of course.