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


Please Help Members By Posting Answers For Below Questions

What is cross join in sql server joins?

793


List some case manipulation functions in sql?

772


How to get @@error and @@rowcount at the same time?

766


What new data source types were added in ssrs 2014?

130


wat wil hapn if we give the both read and deny read permission to user?

1853






List the advantages of using stored procedures?

737


Can two tables share the same primary key?

679


How do I edit a procedure in sql server?

717


how you can configure a running aggregate in SSRS?

131


Mention what are the core components of ssrs?

251


What is the openxml statement in sql server?

722


Difference between Sql server reporting services and Crystal reports?

137


Can you explain powershell included in sql server 2008?

666


What do you understand by triggers?

681


What are the instances when triggers are appropriate?

714