in tabase table having a column in it empname field is
there which having 5 duplicate values is there i want
deleted all the duplicates i want showing only one name
only.

Answer Posted / jiri

WITH DUPLICATE(EmpName, RowNumber)
AS
(SELECT EmpName,ROW_NUMBER() OVER (PARTITION BY EmpName
order by EmpName) AS RowNumber
FROM Employee)

DELETE FROM DUPLICATE WHERE RowNumber > 1

------------------------------------------------------------
Using CTE (Common Table Expressions) and ROW_NUMBER as
ranking fucntion


Jiri JANECEK
MSE, MBA, MCSD.NET

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When you should use a low fill factor?

716


Can you type more than one query in the query editor screen at the same time?

770


How to how to convert numeric expression data types using the convert() function??

722


What is the purpose of sql profiler in sql server?

699


You want to implement the one-to-one relationship while designing tables. How would you do it?

717






How to get the definition of a stored procedure back?

708


What is sub-query in sql server?

877


When columns are added to existing tables, what do they initially contain?

799


What are different types of constraints?

692


What are different backups available in sql server?

757


How can we use ConnectorJ JDBC Driver with MS SQL?

733


Do you know what is openxml in sql server?

806


How many types of objects are there?

685


How to create a scrollable cursor with the scroll option?

671


Is there any difference between primary key and unique with the not null condition?

702