DZone
Database Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Database Zone > How to find duplicate row in a table - MSSQL

How to find duplicate row in a table - MSSQL

Arun Mathew user avatar by
Arun Mathew
·
Sep. 01, 08 · Database Zone · Interview
Like (0)
Save
Tweet
18.27K Views

Join the DZone community and get the full member experience.

Join For Free

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.

Database

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Deployment of Low-Latency Solutions in the Cloud
  • Java: Why Core-to-Core Latency Matters
  • Refactoring Java Application: Object-Oriented And Functional Approaches
  • Open Source Security Risks

Comments

Database Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo