how to delete duplicate rows from table in sql server

Answer Posted / sanjay kumar dinda

Deletion of Rows depends upon the different condition...
Consider based on n columns the entire recordset is
treating a duplicate... We can delete the duplicate by
using following method...

Add one column and set uniue values to that column..

ALTER TABLE TABLE1 ADD ID INT IDENTITY(1,1)

COnsider T contains 40 columns and based on C1,C2,C3 we
have to find the duplicate and we have to delete the same...


Delete T1

FROM TABLE1 T1,TABLE1 T2
WHETE T1.C1=T2.C1 AND
T1.C2=T2.C2 AND
T1.C3=T2.C2
AND T1.ID>T2.ID


I think this will help....

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to restore performance issues and how to check?

1527


What is difference between rollback immediate and with no_wait during alter database?

579


Where is localdb stored?

563


What is full outer join in sql server joins?

571


What factors you will consider calculating the storage requirement for that view?

552






Why is there a performance difference between two similar queries where one uses union and the other uses union all?

514


What is a benefit of using an after insert trigger over using a before insert trigger?

519


What is the optimization being performed in oracle and SQL Server?

632


hi, the following are the outputs of sp_spaceused and sp_tempdbspace sp_spaceused ------------ database size unallocated size tempdb 77752.95 MB 28026.99 MB sp_tempdbspace ------------- database size spaceused tempdb 77752.945312 1.007812 the unused space in sp_spaceused is nearly 28 Gb and in sp_tempdbspace is nearly 76 Gb cany any one explain about this output and why its giving different results.

2474


What are ddl (data definition language) statements for tables in ms sql server?

549


What is the use of nvl work?

565


What are the security related catalog views? : sql server security

538


What is the difference between rank and dense_rank?

505


How do I create a trace in sql server?

518


Is ssrs support other database except ms sql server?

96