How to find the duplicate records on certain fields in SQL Server ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

You can use the group by and having clause in your T-SQL query to find out the duplicate records from the table.

How to find the duplicate records on certain fields in SQL Server ?

Lets have a look at the query that uses the group by and having clause on the Person table in the AdventureWorks database. The firstname column is used as the criteria to find out if the records are duplicate.

Use AdventureWorks2014
GO
select FirstName, count(*) as count
  from Person.Person
  group by FirstName
  having count(*) > 1
image
Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

%d bloggers like this: