You need to reference the CTE in the delete statement…
WITH a as
(
SELECT Firstname,ROW_NUMBER() OVER(PARTITION by Firstname, empID ORDER BY Firstname)
AS duplicateRecCount
FROM dbo.tblEmployee
)
--Now Delete Duplicate Records
DELETE FROM a
WHERE duplicateRecCount > 1
More Related Contents:
- sql server convert date to string MM/DD/YYYY
- Optional multi-valued parameters in SSRS
- Java: Finding duplicate in array [closed]
- Duplicate number and it value in column EXCEL [closed]
- How can I remove duplicate rows?
- Drop all duplicate rows across multiple columns in Python Pandas
- How to prevent duplicate usernames when people register?
- Remove pandas rows with duplicate indices
- Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated
- Algorithm: efficient way to remove duplicate integers from an array
- JQuery: Remove duplicate elements?
- Filter/Remove rows where column value is found more than once in a multidimensional array
- Select query to remove non-numeric characters
- Fastest way to remove duplicate documents in mongodb
- Group duplicate column IDs in pandas dataframe
- Find duplicate lines in a file and count how many time each line was duplicated?
- Partition Function COUNT() OVER possible using DISTINCT
- Prevent auto increment on MySQL duplicate insert
- Error: java.util.zip.ZipException: duplicate entry
- Deleting duplicate rows from a table
- Connecting to MS SQL Server with Windows Authentication using Python?
- Finding duplicate values in arraylist
- Find all duplicate documents in a MongoDB collection by a key field
- A connection was successfully established with the server, but then an error occurred during the login process. (Error Number: 233)
- Remove duplicate items from an array [duplicate]
- Delete duplicate rows in two columns simultaneously [duplicate]
- Detect when multiple enum items map to same value
- Using IF ELSE statement based on Count to execute different Insert statements
- Convert from DateTime to INT
- Check for duplicates before inserting