How can I delete duplicate rows in a table

后端 未结 13 1402
情歌与酒
情歌与酒 2020-12-08 22:30

I have a table with say 3 columns. There\'s no primary key so there can be duplicate rows. I need to just keep one and delete the others. Any idea how to do this is Sql Serv

13条回答
  •  没有蜡笔的小新
    2020-12-08 23:27

    Add an identity column to act as a surrogate primary key, and use this to identify two of the three rows to be deleted.

    I would consider leaving the identity column in place afterwards, or if this is some kind of link table, create a compound primary key on the other columns.

提交回复
热议问题