Link to home
Start Free TrialLog in
Avatar of dkilby
dkilbyFlag for Canada

asked on

MS SQL Delete Duplicate Rows Only

I am using the below queries to identify duplicate rows in a table, and want to delete just the duplicate rows, and keep the original single row,  how would I do that, without losing all my data.

Thanks

select  s.id, t.*
from [CHAT_ChatVolumes] s
join (
    select intervaldate, chats, count(*) as qty
    from [CHAT_ChatVolumes]
    group by intervaldate, chats
    having count(*) > 1
) t on s.intervaldate = t.intervaldate and s.chats = t.chats
 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkilby

ASKER

thank you