初级:
update T_PROFITSHARE set id=t1.rowId from
(select C_TICKETID
ROW_NUMBER() over(Order by C_TICKETID) as rowId
from T_PROFITSHARE) as t1
where
t1.C_TICKETID=T_PROFITSHARE.C_TICKETID
如果需要更新的里面还有重复的字段
增加条件就行了
update T_PROFITSHARE set id=t1.rowId from
(select C_TICKETID,A,B,
ROW_NUMBER() over(Order by C_TICKETID,A,B) as rowId
from T_PROFITSHARE) as t1
where
t1.C_TICKETID=T_PROFITSHARE.C_TICKETID
AND t1.A=T_PROFITSHARE.A
AND t1.B==T_PROFITSHARE.B
本文转自 cd1989929 51CTO博客,原文链接:http://blog.51cto.com/chend/1553049