Please give me queries for the following
1. To get the count of duplicate records.
2. A query to delete the duplicate records.

Answer Posted / meher

1. To get the duplicate records.
Use group by clause to the column on which you want to
check the duplicates records.
syntax:
select column_name, count(*) from table_name group by
column_name having count(*) >1

2. To delete the duplicate records.
syntax:
delete from table_name where rowid in (select max(rowid)
from table_name group by column_name having count(*)>1 )

This will work.
Please let me know in case of any issues.

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a subquery in a select query statement in ms sql server?

580


How to define the name and server for a new dsn?

545


What is the fillfactor concept in indexes?

528


What is the cpu pressure?

562


How to name query output columns in ms sql server?

536






What are entities and relationships?

548


How to loop through result set objects using odbc_fetch_row()?

465


What is ddl command?

528


What is the difference between sql server 2000 object owner and sql server 2005 schema? : sql server database administration

585


What are the different types of triggers in SQL SERVER?

537


What are drillthrough reports?

102


What is raiseerror? What is raiseerror?

639


Define clusters?

643


What is a trigger in sql server?

528


What do you understand by the analysis services in sql server?

532