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 purpose of indexes?
Define compound operators?
How many ways to create table-valued functions?
Which sql server table is used to hold the stored procedure script?
How to create a new schema in a database?
What is dirty read?
where the connection string store in the database
What is report server project?
Which are the olap features?
How to create a view using data from another view?
How to recover from sql injection? : sql server security
hi, how to link a text file and a .rpt file in my tables of sql server and to retrieve those records for further use. reply me as soon as possible.
Can sql server 2016 run on windows 7?
Explain isolation levels that sql server supports?
Is oracle faster than sql server?