Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Does anybody knows the sql code to check for Dups

Author  Topic 

NewToSQLserver
Starting Member

6 Posts

Posted - 2011-01-01 : 07:44:20
Does anybody knows the sql code to check for Duplicate rows?
Any help is appreciated!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-01-01 : 08:09:04
Yes, there are a number of differenf approaches depending on what you want to achieve.
DELETE  f
FROM (
SELECT ROW_NUMBER() OVER (PARTITION BY CustomerID ORDER BY StatusDate DESC) AS RecID
FROM dbo.Table1
) AS f
WHERE RecID > 1



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-04 : 12:48:49
what according to you represent a duplicate?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -