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
Explain the properties of sub-query in sql server?
What is the guest user account in sql server? What login is it mapped to it? : sql server security
Can you always create a cache of a report?
Define master database?
Can one drop a column from a table?
What you can do to delete a table without the delete trigger firing?
What are types of scd? : sql server analysis services, ssas
How exceptions can be handled in sql server programming?
explain extended properties
What are the advantages of using stored procedures?
How important do you consider cursors or while loops for a transactional database?
Can the “if update (colname)” statement be used in a delete trigger?
explain different types of backups avaialabe in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration
What are rows and columns?
Explain how to integrate the ssrs reports in application?