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 / harshad lakkad (bapunagar part
For Count Duplicate---
SELECT YourColumn, COUNT(*) TotalCount
FROM YourTable
GROUP BY YourColumn
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC
For delete Duplicate---
DELETE
FROM MyTable
WHERE ID NOT IN
(
SELECT MAX(ID)
FROM MyTable
GROUP BY DuplicateColumn1, DuplicateColumn2,
DuplicateColumn2)
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
List out different types of normalizations in sql server and explain each of them?
What is a synonym for manipulation?
What are null values in ms sql server?
What is data file in computer?
What are different types of collation sensitivity?
What are the basic functions for master, msdb, model, tempdb and resource databases? : SQL Server Architecture
Can I run multiple instances of sql server 2000 at the same time on one computer?
Does union all remove duplicates?
What is default constraint?
Which operator do you use to return all of the rows from one query except rows are returned in a second query?
what is normalization? Explain different levels of normalization? : Sql server database administration
What is a print index?
Ms sql server index?
Explain the use of keyword with encryption. Create a store procedure with encryption?
Difference Between ORDER BY Clause and GROUP BY Clause in SQL?