Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi to all,
how can I remove duplicate values from table?
Posted
Updated 30-Jul-12 0:31am
v3
Comments
Kenneth Haugland 30-Jul-12 6:27am    
AS you have a uniqe ID column in the SQL database no values are the same.
OriginalGriff 30-Jul-12 6:39am    
That's true :laugh: - but it can be a problem if a customer is entered by a number of people who don't realise they already exist.
Karthik Harve 30-Jul-12 6:39am    
tell us what exactly you wanted to do?

try this.


SQL
select * from temp;

with a as
(
    select row_number() over(partition by id,updateddate order by id) as rn
    from temp
)
delete from a where rn > 1

select * from temp



The output:
3 2012-05-24 10:22:08.523
3 2012-05-24 10:22:08.523


3 2012-05-24 10:22:08.523
 
Share this answer
 
Comments
Aarti Meswania 1-Nov-12 0:48am    
5+
There is a method suggested here: Remove Duplicate Rows from a Table in SQL Server[^] - but read the messages as they suggest some others.
 
Share this answer
 
Comments
panduu 30-Jul-12 11:42am    
Thanks for sending and it should be understandble

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900