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
what is the difference between Delete and Truncate command in SQL
List out different types of normalizations in sql server and explain each of them?
What are the advantages of user defined function?
Why would you use sql agent?
How check triggers in sql server?
Explain what is log shipping?
What is xdr?
Explain how would you store your query in an SSRS report or a Database server?
What is an sql server agent?
What are the various editions of sql server 2017 that are available in the market?
Does transparent data encryption provide encryption when transmitting data across the network?
Which tcp/ip port does sql server run on? How can it be changed?
Do you know what are the ways available in sql server to execute sql statements?
you accidentally delete the msdb database what effect does this have on your existing sql databases, and how do you recover? : Sql server administration
What is faster join or union?