Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 does REVERT do in SQL Server 2005?

963


what is the difference between Delete and Truncate command in SQL

1148


What is create statement?

959


Is there any performance difference between if exists (select null from table) and if exists (select 1 from table)?

971


What is temporal data type?

922


Explain how many types of relationship?

1030


What is a trigger? Why we need it?

996


How you provide security to cube? : sql server analysis services, ssas

965


Mention a few common trace flags used with sql server?

931


What is tabulation?

952


What are the extra roles available in msdb? : sql server security

1135


What are the pre-defined functions in the sql server?

1112


What is the sql profiler?

942


Explain Geography datatype in SQL Server

1131


What is view in sql?

906