Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to find duplicate row in a table - MSSQL

DZone's Guide to

How to find duplicate row in a table - MSSQL

· Database Zone ·
Free Resource

Download the Altoros NoSQL Performance Benchmark 2018. Compare top NoSQL solutions – Couchbase Server v5.5, MongoDB v3.6, and DataStax Enterprise v6 (Cassandra).

The below given query will fetch the duplicate rows in MSSQL with number of occurance of each row.

SELECT     <all column names - comma seperated>, COUNT(<name of any one column>) AS Occurance_Count
FROM <table name>
GROUP BY <all column names - comma seperated>
HAVING (COUNT(<name of any one column>) > 1)

 

Note: The data in '<>' should be replaced with relevent data. E.g. '<all column names - comma seperated>' should be replaced with 'a,b,c' where a, b and c are the names of the columns in the table.

Download the whitepaper, Moving From Relational to NoSQL: How to Get Started. We’ll take you step by step through your first NoSQL project.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}