Update one of 2 duplicates in an sql server database table

前端 未结 11 1215
长发绾君心
长发绾君心 2020-12-05 00:48

I have got a table that got a column with duplicate values. I would like to update one of a 2 duplicate values so for example row1 = tom and row2 = tom

11条回答
  •  伪装坚强ぢ
    2020-12-05 01:27

    update wmwhse1.sku
    set descr= concat (descr,'.')
    where exists
    (select SKU,count (DESCR)
    from wmwhse1.sku
    group by descr
    having (count (DESCR)>1))
    

    all sku description is updating when I run this script.

    output: only 1 row should be affected

提交回复
热议问题