Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

More...

Forums » .NET » .NET »

how to delete the duplicate rows in table?


Posted Date: 05 Sep 2006      Posted By:: jaya sree     Member Level: Silver    Member Rank: 0     Points: 2   Responses: 3



how to delete the duplicate rows in table?




Responses

#74124    Author: Rajaraman      Member Level: Gold      Member Rank: 80     Date: 05/Sep/2006   Rating: 2 out of 52 out of 5     Points: 2

Hi

Try this

Select * from EmpTable where Empid not in(select max(Empid) from Emptable group by EmpName)

Regards,
Rajaraman. B
Visualsoft Technologies



 
#74171    Author: Afroz Khan      Member Level: Gold      Member Rank: 0     Date: 06/Sep/2006   Rating: 2 out of 52 out of 5     Points: 2

try this query this must solve your query:-


-- key_value is the name of the column in the original_table table in my database.

SELECT DISTINCT *
INTO duplicate_table
FROM original_table
GROUP BY key_value
HAVING COUNT(key_value) > 1

DELETE original_table
WHERE key_value
IN (SELECT key_value
FROM duplicate_table)

INSERT original_table
SELECT *
FROM duplicate_table

DROP TABLE duplicate_table


Let me know if you have any more queries related to this.

Regards,
Afroz Khan.
http://khanafroz.blogspot.com/



 
#78233    Author: Sandeep Kumar      Member Level: Silver      Member Rank: 0     Date: 18/Sep/2006   Rating: 2 out of 52 out of 5     Points: 2

Just copy distinct record in another table delete first table rename 2nd table to first table





 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : how to add css to controls?
Previous : difference b/w primary key & unique key?
Return to Discussion Forum
Post New Message
Category:

Related Messages
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.