How can I delete duplicate rows in a table

后端 未结 13 1372
情歌与酒
情歌与酒 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:07

    Manrico Corazzi - I specialize in Oracle, not MS SQL, so you'll have to tell me if this is possible as a performance boost:-

    1. Leave the same as your first step - insert distinct values into TABLE2 from TABLE1.
    2. Drop TABLE1. (Drop should be faster than delete I assume, much as truncate is faster than delete).
    3. Rename TABLE2 as TABLE1 (saves you time, as you're renaming an object rather than copying data from one table to another).

提交回复
热议问题