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
 Delete duplicate ROWS

Author  Topic 

Nitin Bansal
Starting Member

13 Posts

Posted - 2008-06-18 : 03:31:20
How to delete duplicate records from table ? Is there any query for that ?
I am using SQL 2005.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-18 : 03:49:27
Yes.

DELETE f
FROM (SELECT ROW_NUMBER() OVER (PARTITION BY Col1 ORDER BY Col2 DESC) AS RecID FROM Table1) AS t
WHERE RecID > 1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Nitin Bansal
Starting Member

13 Posts

Posted - 2008-06-18 : 06:39:08
I am unable to understand your query. Can you please describe me ? I have 10 Columns in my table, and i want when all the col values are matches with the second row then the same row should deleted.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-18 : 07:43:01
PARTITION BY more columns...

You know you are allowed to open and read about functions and how they are used, in Books Online (the SQL Server help file)?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -