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 is cross join in sql server joins?
List some case manipulation functions in sql?
How to get @@error and @@rowcount at the same time?
What new data source types were added in ssrs 2014?
wat wil hapn if we give the both read and deny read permission to user?
List the advantages of using stored procedures?
Can two tables share the same primary key?
How do I edit a procedure in sql server?
how you can configure a running aggregate in SSRS?
Mention what are the core components of ssrs?
What is the openxml statement in sql server?
Difference between Sql server reporting services and Crystal reports?
Can you explain powershell included in sql server 2008?
What do you understand by triggers?
What are the instances when triggers are appropriate?