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

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
%d bloggers like this: