Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

DELETE DUPLICATE VALUES FROM A TABLE IN SQL SERVER

WITH cte AS (
    SELECT 
        contact_id, 
        first_name, 
        last_name, 
        email, 
        ROW_NUMBER() OVER (
            PARTITION BY 
                first_name, 
                last_name, 
                email
            ORDER BY 
                first_name, 
                last_name, 
                email
        ) row_num
     FROM 
        sales.contacts
)
DELETE FROM cte
WHERE row_num > 1;
Code language: SQL (Structured Query Language) (sql)
Source by www.sqlservertutorial.net #
 
PREVIOUS NEXT
Tagged: #DELETE #DUPLICATE #VALUES #FROM #A #TABLE #IN #SQL #SERVER
ADD COMMENT
Topic
Name
5+3 =