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
What does REVERT do in SQL Server 2005?
what is the difference between Delete and Truncate command in SQL
What is create statement?
Is there any performance difference between if exists (select null from table) and if exists (select 1 from table)?
What is temporal data type?
Explain how many types of relationship?
What is a trigger? Why we need it?
How you provide security to cube? : sql server analysis services, ssas
Mention a few common trace flags used with sql server?
What is tabulation?
What are the extra roles available in msdb? : sql server security
What are the pre-defined functions in the sql server?
What is the sql profiler?
Explain Geography datatype in SQL Server
What is view in sql?