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 store procedure?
When would you prefer to have a minimum number of indexes?
What is the difference between a stored procedure and a user defined function?
Why we use functions in sql server?
What command is used to rename the database?
Explain the different types of joins?
Can we run Reporting Services with SQL Server express edition, which is a free version of SQL Server?
how many clustered indexes can be created on a table? : Sql server database administration
Explain Geography datatype in SQL Server
What do you understand by coalesce in sql server?
What are the steps to take to improve performance of a poor performing query? : sql server database administration
How to write the storeprocedure with in the store procedure? and how can we write the store procedure with in a trigger vice versa? plz post me the exact answer?
what are the types of indexes? : Sql server database administration
How to trouble shoot if unable to connect SQL Server
What is 2nf normalization?