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
How would you add a section to a table?
Why are you getting errors when creating a new odbc dsn?
What is difference between table aliases and column aliases? Do they affect performance?
What is resource db in sql server?
How to enter comments in transact-sql statements?
How to call stored procedure using http soap?
What is a result set object returned by odbc_exec()?
What is outer join in sql server joins?
What is bookmark link in ssrs?
What is the difference between grant and with grant while giving permissions to the user?
What are the different types of Indexes available in SQL Server?
Why and when do stored procedure recompile?
Suppose you want to implement the one-to-many relationships while designing tables. How would you do it?
What is correlated subquery in sql server?
How to copy the tables, schema and views from one sql server to another?