SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 not sure if correct place but...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dph1974
Starting Member

United Kingdom
1 Posts

Posted - 02/12/2013 :  18:05:46  Show Profile  Reply with Quote
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)

Singapore
17682 Posts

Posted - 02/13/2013 :  02:13:21  Show Profile  Reply with Quote

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


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


KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000