Delete script SQL Server 2008

后端 未结 2 692
别那么骄傲
别那么骄傲 2021-01-24 02:50

Here is a situation that I am trying to resolve. I have a table that is loaded with duplicates. It happened because similar rows were loaded from two different sources. That is

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-24 02:57

    Maybe it will help you

    ;WITH cte AS
     (
      SELECT ROW_NUMBER() OVER (PARTITION BY UID, ADDRESS, City, State, Zip, DataSource ORDER BY UID) AS Dup
      FROM dbo.F_staRes
      )
    DELETE cte
    WHERE Dup > 1
    

提交回复
热议问题