Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

delete duplicate data from table

WITH CTE([FirstName], 
    [LastName], 
    [Country], 
    DuplicateCount)
AS (SELECT [FirstName], 
           [LastName], 
           [Country], 
           ROW_NUMBER() OVER(PARTITION BY [FirstName], 
                                          [LastName], 
                                          [Country]
           ORDER BY ID) AS DuplicateCount
    FROM [SampleDB].[dbo].[Employee])
DELETE FROM CTE
WHERE DuplicateCount > 1;
/*will delete the duplicate value*/
Source by www.sqlshack.com #
 
PREVIOUS NEXT
Tagged: #delete #duplicate #data #table
ADD COMMENT
Topic
Name
1+1 =