How to query duplicate records in SQL Server 2000 database

Source: Internet
Author: User

1. Search for redundant duplicate records in the Table. duplicate records are determined based on a single field (account ).
Select * From myehome where account in (select account from myehome group by account having count (account)> 1)

PS: myehome table name account the field name having count to be re-checked Function

2. Search for redundant duplicate records in the table (multiple fields)
Select * From myehome

Where account in (select account from myehome group by account, name having count (*)> 1) and name in (Select name from myehome group by account, name having count (*)> 1)
PS: query records with duplicate accounts and names at the same time
Two or more fields need to be written after the WHERE clause, because in can only be a single condition. peopleid,. SEQ) in (select peopleid, seq from vitae group by peopleid, seq having count (*)> 1) "is an error. No other simple statements are found.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.