Code.GeekInterview.com
 
Code Samples SQL Server
 

Delete Duplicate Records


Code ResourceAuthor: gupt_12  

Difficulty Level:

Published: 6th Nov 2006   Read: 5935 times  

Filed in: SQL Server
Add Comment


 

 

Sponsored Links


 

 

Removing Duplicate Records in Sql. Execute the below statements in sequence

 


Sample Code
  1.  
  2. SELECT * FROM table1
  3. SELECT DISTINCT * INTO table2 FROM table1
  4. DELETE table1
  5. INSERT INTO table1 SELECT * FROM table2
  6. SELECT * FROM table1
  7. DROP TABLE table2
  8.  
Copyright GeekInterview.com


Next: Change to Proper case Function


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Comments

In oracle we have rowid to uniquely identify every records. Do we have anything of that sort in DB2.

Because this would be a time consuming process if number of constraints/indexes defined on the table are more.

Comment posted by: jamesravid on 2006-11-23T06:04:11
The code is good . but it is getting slow when we handle the large tables for duplicate deleting.
Comment posted by: Rajesh Sampath on 2011-03-03T10:10:32

Popular Coders

# Coder NameHits
1. Jim.Anderson6290
2. gupt_125936

Active Coders

# Coder NameCodes
1. gupt_121
2. Jim.Anderson1

Refined Tags