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
 not sure if correct place but...

Author  Topic 

dph1974
Starting Member

1 Post

Posted - 2013-02-12 : 18:05:46
can some 1 help me with removing duplicate rows in a database, i am a total novice at this and the things i have read about deleteing duplicate rows have lost me , im using sql2005 the field names that will show the duplicates are i think FLD_MAPNAME FLD_X FLD_Y and FLD_MONNAME if anyone can help me would be great either with a script or via team viewer maybe

thanx

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-02-13 : 02:13:21
[code]
DELETE D
FROM
(
SELECT *, RN = ROW_NUMBER() OVER (PARTITION BY FLD_MAPNAME , FLD_X , FLD_Y , FLD_MONNAME
ORDER BY FLD_MAPNAME , FLD_X , FLD_Y , FLD_MONNAME)
FROM yourtable
) D
WHERE RN <> 1
[/code]

Do make sure you have backup before executing it, it case it is not what you wanted


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -