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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:51:47+00:00 2026-06-16T04:51:47+00:00

I am looking for an elegant way to copy down a value from a

  • 0

I am looking for an elegant way to copy down a value from a parent tuple to a child. I need it to be copied as it can change independently of the parent value, but that is the baseline to start.

Here is a simplified version of the table:

CREATE TABLE Parent (
    Id INT NOT NULL PRIMARY KEY,
    ParentValue VARCHAR(128)
);


CREATE TABLE Child (
    Id INT NOT NULL PRIMARY KEY,
    ParentId INT NOT NULL FOREIGN KEY REFERENCES Parent(Id),
    ChildValue VARCHAR(128)
);

Now what I am looking to do is this:

   UPDATE Child
   SET ChildValue = Parent.ParentValue
   WHERE TRUE

Does that makes sense? I have a looping way, but it does not seem efficient for the multitude of records I plan on running it for.

  • 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-16T04:51:48+00:00Added an answer on June 16, 2026 at 4:51 am

    You can use the proprietary UPDATE FROM syntax

    UPDATE Child
    SET ChildValue = ParentValue
    FROM Child
    JOIN Parent ON Parent.Id = Child.ParentId;
    

    or the standard SQL MERGE syntax as you are on 2008

    MERGE INTO Child
       USING Parent
          ON Parent.Id = Child.ParentId
    WHEN MATCHED THEN
       UPDATE 
          SET ChildValue = ParentValue;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for an elegant way to change multiple vectors' datatypes in R. I'm
i am looking for a easy & elegant way to change my appsettings in
I'm looking for an elegant way to return multiple values from one subtemplate. why?
I'm looking for an elegant way to select fields from a view, where a
I'm looking for a elegant way to assign the value stored inside an Hash
I am looking for an elegant way to checkout a file from a particular
I'm looking for an elegant way to transform an std::string from something like: std::string
I'm looking for most elegant way to ajaxify my forms (with jQuery). How do
I'm looking for an elegant way to suppress exceptions when calling a method. I
I'm looking for an elegant way to generate a sequence of the rolling average

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.