Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9112225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:41:02+00:00 2026-06-17T03:41:02+00:00

I’m trying to figure out the means to do two things: Locate duplicate records

  • 0

I’m trying to figure out the means to do two things:

  1. Locate duplicate records in a table.

These are typically duplicate names in the ‘Name’ column but
specifically those where the ParentID is the same. It’s fine if I
have identical names where the ParentID is different because these
names (or Children) belong to different parents.

  1. Modify these duplicates.

Preferably, I would modify these duplicates by appending the ‘ID’ to the name.

I came up with a query to locate duplicates and them dump them into a temp table:

CREATE TABLE #Dup(
Name varchar(50),
CustNo varchar(7))

insert into #Dup (Name, CustNo)
SELECT [Name],[CustNo]

FROM [02Kids]
GROUP BY [Name], [CustNo]
HAVING Count(*)>1

This seems to work. When I view the data in the table I see the name and I see the ParentID identifying that indeed, this is a name that appears twice for that parent ID. Its worth noting that the name only appears once in the table. It doesn’t show two rows with the same name and ID (perhaps this is part of my problem).

Here’s the query I came up with attempting to perform the modification:

select[#Dup].[Name] + '  ' + [02Kids].[ID] as iName, [02Kids].ParentID 
from #Dup
inner join [02Kids]
on #Dup.CustNo = [02Kids].ParentID 
order by iName asc

Well, this sort of works, except I end up with massive amounts of duplicates. For example, one “Name” that I can confirm only has two duplicates ends up with close to 13 in total from that select query.

I may be way off here with that query (this is practice stuff I’m using to teach myself) but I’m having trouble conceiving a correct means to do this. I am still learning syntax, keywords, functions, etc so maybe there’s something I should use I just don’t know of yet.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:41:03+00:00Added an answer on June 17, 2026 at 3:41 am

    Well to only get the matches you want in your “modification” query you’ll need to add a match on name to your join clause. Right now you are matching your duplicate record to every kid for that parent, not just the duplicates. So if one parent has 13 kids, only one of which is a duplicate, you’ll get 13 extra records.

    inner join [02Kids]
    on #Dup.CustNo = [02Kids].ParentID AND
    #Dup.Name = [02Kids].Name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.