Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

SQL Server Query to Get Count of Duplicate Records from Table

Jun 6, 2012
Introduction:

Here I will explain how to write a query to get duplicate records from table in sql server or Query to get count of duplicate records or rows in SQL Server or query to find duplicate records in SQL server.

Description:

In previous post I explained Query to alter table columns and Query to delete duplicate records in SQL Server. Now I will explain how to write SQL query to get duplicate records count that means how many times each duplicate record exists in datatable. In database I have one table that doesn’t contain any primary key column because of that duplicate records inserted in table that would be like this 

Now I want to know the duplicate records count that means how many times each duplicate record exists in datatable for that I written a query like this


SELECT Id,Name, COUNT(*) as DupeCount
FROM EmployeData
GROUP BY Id,Name
HAVING COUNT(*) > 1 Order By Id
After run above query we will get each record duplicate count that would be like this

 If you want to delete duplicate records or rows from datatable check this link Query to delete duplicate records in SQL server

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

5 comments :

Anonymous said...

You Develop a very good website..

kulasekaralwar said...

Can u please give example to redirect to gmail accout. I gmail username and gmail password only when they click gmail-Button it should redirect to gmail account. Please show with some example

Thanks in advance

Prasanta Kr. Biswas said...

Actually need to specified how to write code for C# checking duplicate record through entering text box

Unknown said...

my data contains where an employee is assigned to many projects while most of the employees are assigned only one project. My object is to report to management the names of persons assigned to more than one project. Please help to create suitable query in Access 2007

Anonymous said...

LOOSERS!!!!!!!

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.