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

<<  September 2025  >>
MoTuWeThFrSaSu
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

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

"The distance between insanity and genius is measured only by success."
Bruce Feirstein