|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Finding and updating all rows with the same value in a columnThis integer column should be unique, så prior to altering it to unique i
need to traverse all rows and update the rows with the same value. This table has another colun which is the primary key and when 2 rows has the same value the row with the highest value of the primary key will be updated. Any easy T-SQL way to do it? Regards, Olav update your_table
set your_column = whatever you wish to set it to where exists(select 1 from your_table yt where your_table.your_column = yt.your_column and your_table.PK_column > yt.PK_column) Just curious: what kind of information do you have in that column so that you can easily update it just to enforse uniqueness? |
|||||||||||||||||||||||