SQL:Remove Duplicates

by ssi 21. February 2016 12:05

DELETE FROM [ssi_tbl_NameAddress]

WHERE  control NOT IN (SELECT MAX(control)

                  FROM   [ssi_tbl_NameAddress]

                  GROUP  BY Lname,fname 

                  /*Even if ID is not null-able SQL Server treats MAX(ID) as potentially

                    nullable. Because of semantics of NOT IN (NULL) including the clause

                    below can simplify the plan*/

                  HAVING MAX(control) IS NOT NULL) 

Tags:

SQL

Add comment

biuquote
  • Comment
  • Preview
Loading

Calendar

<<  July 2025  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

RecentComments

None

Development Team @ Shelbysys

We develop custom database applications for our clients. Our development tool of choice is MS Visual Studio. 

Quotations

"Fill the unforgiving minute with sixty seconds worth of distance run."
Rudyard Kipling