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
How to configure odbc dsn with different port numbers?
How to update multiple rows with one update statement in ms sql server?
What are the properties of the transactions?
What is the use of floor function in sql server?
How to copy data from one table to another table?
What is the use of attributehierarchyvisible ? : sql server analysis services, ssas
What are the database objects? : SQL Server Architecture
Define tempdb database?
What are partitioned views and distributed partitioned views?
When would you use it?
What is logon trigger?
Where do you find the default Index fill factor and how to change it?
How to insert stored procedure result into temporary table?
What is the tcp/ip port on which sql server runs?
How to include date and time values in sql statements?