How to update distinct column in SQL Server 2005?
问题 In my table I have a column Segment_No which has duplicates. Now I want to update those duplicates. For example: the value 249X5601 is present in two rows. I want to change the second value to 249X5601R 回答1: The general form would be as follows: ;with AllRows as ( select Donation_ID,Registration_No,Segment_No, ROW_NUMBER() OVER ( PARTITION BY Segment_No order by <Suitable_Column> ) as rn from UnnamedTable ) update AllRows set Segment_no = <New_Value> where rn > 1 Where <Suitable_Column> gives