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 7616101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:48:30+00:00 2026-05-31T02:48:30+00:00

I have a parent table (Person) with a child table (Address). I need to

  • 0

I have a parent table (Person) with a child table (Address). I need to send all person and address combinations to a service to be processed, but I am restricted in that I can only send up to 10,000 at a time. When I send data for a person I need to make sure I send all of the data for that person, so they can’t be split across batches.

I want to be able to pull the data using SQL only, no additional code (this is to be used in an SSIS package).

Example: I want to pull only max of 5 from the data below

---Person---  ---------Address----------
ID  Name      AddressID    Address
--- --------  ------------ -------------
1   Bill      1            1 The Street
1   Bill      2            3 The Road
2   Jeff      3            7 The Hill
3   Mike      4            9 The Avenue
4   Ross      5            11 Main Road     --- This is the 5th row, must be ignored
4   Ross      6            12 Down Under    --- This record would be orphaned if 
                                                we pulled top 5

  • 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-05-31T02:48:32+00:00Added an answer on May 31, 2026 at 2:48 am

    I found this seemed to be the best way to do it:

    WITH data AS
    (
          select TOP 10001 ROW_NUMBER() OVER (ORDER BY p.PersonID) as [Rank], 
                 p.PersonID, a.AddressID
          from Input.Person p
          JOIN Input.Address a on p.PersonID = a.PersonID
    )
    
    select d1.*
    FROM data d1
    LEFT JOIN data d2 on d1.PersonID = d2.PersonID
          AND d2.[RANK] > 10000 
    WHERE d1.[RANK] <= 10000
    AND d2.PersonID IS NULL
    ORDER BY 1
    

    The TOP 10001 allows me to limit the data searched as if the 10000th and 10001st record share a parent, then the 10000th should be ignored.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have (all InnoDB) a parent table tbl1 with primary key some_id and child
If I have a parent table and a child table where there can be
I have a simple parent/child tables. Contract is the parent table. Each contract can
So I have a parent that defines a onmouseup event that hide/display a table.
I have db table with parent child relationship as: NodeId NodeName ParentId ------------------------------ 1
I have a table which defines a child-parent relationship between nodes: CREATE TABLE node
I have two parent tables, BusinessGroup and SocialGroup, and one child table, Members. A
In sql server 2005, I have a parent table describing paths, and a child
I have this person table as super parent, id firstname lastname email telephone ...
I have parent and child entries in same table, For differentiate i have added

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.