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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:11:30+00:00 2026-06-18T12:11:30+00:00

Background Information For some reason, while inserting a huge data into multiple tables from

  • 0

Background Information

For some reason, while inserting a huge data into multiple tables from xml, my primary keys are shifted by an offset.. (Maybe because of multiple failed attempts :P)

I have two tables.. tableA and tableB. They are in one-to-may relationship.
tableA is the parent table and has the Primary key column …say DataIndex.

now DataIndex has come out like this..

685, 686, 687… and so on.

and corresponding values present in the child table i.e TableB are the same.

Problem

How do I shift the values up so that DataIndex start from 1, 2, 3..and so on; In both tables ?

  • 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-18T12:11:31+00:00Added an answer on June 18, 2026 at 12:11 pm

    I’m assuming that the primary key is actually an identity column that auto-increments itself upon insertion. What you will need to do is ‘reseed’ the identity column. You can do this by renaming the table, create a duplicate table with the original name, then inserting the data from the old table to the new one (the primary key field will be reset and will auto-increment from 1 again). When doing the insertion, make sure to include the old primary key value as an additional column for reference in the other tables.

    To match up the related table, all you will need to do is do an UPDATE and join to your new table on the old primary key value:

    UPDATE tableB SET
       PRIMARYKEYCOLUMN = tableA.PRIMARYKEYCOLUMN
    FROM tableA
    WHERE
       tableA.OLDPRIMARYKEYCOLUMN = tableB.PRIMARYKEYCOLUMN
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyway to create an ObjectSet from a DbSet ? Some background information:
I have a Listview of layouts that prints out some information, for some reason
so first I'll give some background information so you can understand my problem completely.
This is a two part question, but first some background information: I have a
Some background information: We have an ancient web-based document database system where I work,
Some background information: I am creating a Silverlight WCF RIA Services Project. I started
Some Background information We have developed the application against the two most popular standards
And if you do, can you give some background information on the implementation and
Some background information, for a homework assignment I had to write a polish notation
Background Information: Ultimately, I would like to write an emulator of a real machine

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.