Nick Kewney

Software Architect & Product Builder

Deleting duplicate records using T-SQL

WITH cte AS (
SELECT [Field1], [Field2]
 row_number() OVER(PARTITION BY [Field1], [Field2] ORDER BY [Field1]) AS [rn]
 FROM [Table1] WHERE [Column1]=[Condition1]
 )
DELETE cte WHERE [rn] > 1

 

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on whatsapp
WhatsApp

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.