Update sql statement for DELETING DUPS in 2 fields
Posted on 2011-09-26
sql server 2008
What I need:
To delete duplicates based on 2 fields.
In my Table...
field 1 = "Material_no" is a PK field(Yes dups ok).
field2 = "alt_acc_material_no" (pk field no dups)
Right now I'm using cte to delete dups from a table with 1 primary field...
code for one primary field:
with CTE as (
select *, row_number() over (partition by material_no order by material_no) rn
delete from CTE where rn > 1
1A123 4RRT5 < OK
1A123 55T56 < OK
5TT56 666T6 <----- DELETE