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
1)what is the difference between Reinitializing a Subscription and synchronization the subscription? 2)when to use reinitializing ? 3)when to use synchronization? 4)when adding table or deleting a table what to do?(reinz.. or syn) 5)when adding a column what to do?
What command would you use to create an index?
What is scrollable cursor?
Can we update data in a view?
How to receive output values from stored procedures?
Explain about SQLOS?
How do I repair damaged sql server mdf file database? In previous day my mdf file has got damage due to unknown reasons then I used dbcc chekcdb command but it failed, MDF file is important for me, I don’ know that how to get back mdf file data. Please anyone suggest me?
Explain error handling in ssis?
What is the difference between index seek vs. Index scan?
Does index speed up select statements?
Does dbcc checkdb requires db to be in single_user mode? : sql server database administration
What is executereader?
What are blobs, tables, and Queues? Is SQL is the standard way to query blobs, tables, and queues?
What are the types of containers in ssis?
How to run sql server 2005 books online on your local system?