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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:17:43+00:00 2026-06-04T21:17:43+00:00

An existing database has been rolled out to several clients already. Now I developed

  • 0

An existing database has been rolled out to several clients already.

Now I developed a add on and need to transfer my newly added rows of PK-FK tables to the various target dbs. But I can’t just copy the PKs as the target might already use that specific PK and therefore being in unknown state to me when writing the update script…

Any ideas apart from increasing the PK numbers on the source db by, say ten thousand, hoping it will be high enough not to interfer with the target PKs?

Thanks

  • 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-04T21:17:46+00:00Added an answer on June 4, 2026 at 9:17 pm

    I will probably end up

    • adding GUIDs to the tables parallel to my int
      PKs and FKs.
    • Filling those fields with newid() and copying those
      values to the FK tables.
    • Then transfer my newly added rows without the FK data (after disabling check constraints)
    • and then rectify the int FK values using my GUID references.

    gosh that script is gonna take some time…

    Update:
    Thanks to Mikael’s comment I found the solution right before my eyes:

    • I will just add a new “PK shadow” column, defaulting to the PK value.
    • then remove the default (so the target db has null values there when extending the target schema)
    • So after transferring the rows (without identity insert on) I will still have references to the old PK
    • and only need to update all “broken” FKs joining the FK tables with the PK shadow column

    and here are the scripts: http://www.morrenth.com/transferring-some-rows-having-.aspx

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

Sidebar

Related Questions

I have an existing database based on SQLiteOpenHelper that has several versions and code
We have a database that has been deployed to various clients. We are currently
I'm working with an existing database that has first name and last name seperated
I have an existing database in mysql. One of my tables has discontinuous ids.
How to add a existing database file say (ex:- x.sdf) and dump the data
I've been tasked to create a PHP app which accesses an existing PostgreSQL database.
I have an existing site (where nearly every line has been coded by hand)
I have an existing database, which I have been happily accessing using LINQtoSQL. Armed
I have a existing MySQL database which has large number of tables. But the
I know this question has been asked several times, but I would like to

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.