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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:34:50+00:00 2026-06-10T12:34:50+00:00

I have a sitution where I need to import records from a flat file

  • 0

I have a sitution where I need to import records from a flat file into several tables, making sure to keep tab on the resulting Primary keys for each row insert, for insertion into the next table.

Example

For each Row in FlatFile_Import 

    RowID = INSERT Row_ELEMENTS1 INTO TABLEA

    PROPID = INSERT ROW_ELEMENTS2 & ROWID INTO TABLEB

    ATTRID = INSERT ROW_ELEMENTS3 & PROPID INTO TABLEC

    . . .  ..
NEXt 

I have a staging table, StagingTable filled with data from an excel file. Each row of the data in StagingTable contains records that need to be inserted into various tables(TableA, TableB, and TableC). Now when I insert the columns from each row that go to TableA, I need to retrieve the created/generated primarykey, KeyA Next I select to insert the columns from StagingTable row that should go into TableB, along with KeyA, and get back KeyB and so on and so forth.

How can I best handle this requirement please?

  • 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-10T12:34:51+00:00Added an answer on June 10, 2026 at 12:34 pm

    This solution assumes you can Modify the TableA and TableB to add a column.

    Load the Data into StagingTable .Staging table should have StageRecordID ( identity).
    Then you need to modify the TableA to add a colum StageRecordID. Store the StageRecordId in this column when populating TABLEA.
    WHEN populating TableB join the StagingTable with TableA to get RowID of TableA
    similarly Store StageRecordID in TableB aswell so that you can join to it When Populating TABLEC

    Edit:some example code

    --Assuming TableA is 
    
    /*
    CREATE TABLE TABLEA
    {
    RowID INT IDENTITY(1,1)
    ,Row_ELEMENTS1 varchar(25)
    ,StageRecordID int  ---you need to add this column to the Table
    }
    */
    INSERT INTO TABLEA
    (
    Row_ELEMENTS1,
    StageRecordID
    )
       SELECT Col1 AS Row_ELEMENTS1,StageRecordID FROM StaginTable
    
    
    --NOW assuming TABLEB is 
    
    /*
    CREATE TABLE TABLEA
    {
    PROPID  INT IDENTITY(1,1)
    ,Row_ELEMENTS2 varchar(25)
    ,ROWID 
    ,StageRecordID int ---you need to add this column to the Table
    }
    */
    INSERT INTO TABLEB
    (
    Row_ELEMENTS2,
    ROWID,
    StageRecordID
       )
        SELECT a.Col2 AS Row_ELEMENTS2, b.ROWID ,a.StageRecordID FROM StaginTable AS a
        INNER JOIN TABLEA AS b
        ON a.StageRecordID=b.StageRecordID 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where I need to concatenate several string to form an
We have a situation where we need to display data from a database in
I have situation where I need to make sure that user has completed certain
I have a situation where I need to display ItemID and ItemName from Items
So I have situation when I need skip current test from test method body.
In our application we need to import transaction data from paypal through an API
I have situation where I need to change the order of the columns/adding new
I have a situation where I need to dynamically build up a list of
I have a situation where I need to pass two parameters to an action.
I have a situation where I need to update a control referenced in a

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.