Skip to content
Loading
  • Jaydeep Patil
    +2
    Hi,
     
    Check the below URL and try to use as per your table details that work in your case
     
     https://www.sqlservertutorial.net/sql-server-basics/delete-duplicates-sql-server/
     
     
    1. WITH cte AS (  
    2.     SELECT   
    3.         contact_id,   
    4.         first_name,   
    5.         last_name,   
    6.         email,   
    7.         ROW_NUMBER() OVER (  
    8.             PARTITION BY   
    9.                 first_name,   
    10.                 last_name,   
    11.                 email  
    12.             ORDER BY   
    13.                 first_name,   
    14.                 last_name,   
    15.                 email  
    16.         ) row_num  
    17.      FROM   
    18.         sales.contacts  
    19. )  
    20. DELETE FROM cte  
    21. WHERE row_num > 1;  
    +2