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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:04:52+00:00 2026-05-11T06:04:52+00:00

Let’s say you’re running an UPDATE statement on a table, but the information you’re

  • 0

Let’s say you’re running an UPDATE statement on a table, but the information you’re putting into this base table is from some other auxiliary table. Normally, you would JOIN the data and not expect the rows in the UPDATE statement’s FROM clause to multiply, maintaining that one new row maps to one old row in the base table.

But I was wondering what would happen if your JOIN table was ambiguous somehow, like you couldn’t account for each base entity mapping only to one joined entity. Or if you did something nonsensical like join to a base table to a table of its children and updated the base table using that information. How would it choose? Now there are multiple rows per one base table row.

I ran a statement like this in SQL Server 2005 and it seemed to be choosing the first row in each set. But that just seems wrong to me. Shouldn’t it fire an error? Why is this desired behavior?

Example code

-- normal -- categories are one-to-many bundles  update bundles_denormalized set category = c.description  from bundles_denormalized b left join categories c on b.category_id = c.id  -- ambiguous -- bundles are one-to-many products  update bundles_denormalized set category = p.description  from bundles_denormalized b left join products p on b.id = p.bundle_id 
  • 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. 2026-05-11T06:04:53+00:00Added an answer on May 11, 2026 at 6:04 am

    From BOL on UPDATE

    Using UPDATE with the FROM Clause

    The results of an UPDATE statement are undefined if the statement includes a FROM clause that is not specified in such a way that only one value is available for each column occurrence that is updated, that is if the UPDATE statement is not deterministic. For example, in the UPDATE statement in the following script, both rows in Table1 meet the qualifications of the FROM clause in the UPDATE statement; but it is undefined which row from Table1 is used to update the row in Table2.

    USE AdventureWorks; GO IF OBJECT_ID ('dbo.Table1', 'U') IS NOT NULL     DROP TABLE dbo.Table1; GO IF OBJECT_ID ('dbo.Table2', 'U') IS NOT NULL     DROP TABLE dbo.Table2; GO CREATE TABLE dbo.Table1      (ColA int NOT NULL, ColB decimal(10,3) NOT NULL); GO CREATE TABLE dbo.Table2      (ColA int PRIMARY KEY NOT NULL, ColB decimal(10,3) NOT NULL); GO INSERT INTO dbo.Table1 VALUES(1, 10.0); INSERT INTO dbo.Table1 VALUES(1, 20.0); INSERT INTO dbo.Table2 VALUES(1, 0.0); GO UPDATE dbo.Table2  SET dbo.Table2.ColB = dbo.Table2.ColB + dbo.Table1.ColB FROM dbo.Table2      INNER JOIN dbo.Table1      ON (dbo.Table2.ColA = dbo.Table1.ColA); GO SELECT ColA, ColB  FROM dbo.Table2; 

    In other words, it is a valid syntax and it is not going to throw an error or exception.

    But at the same time you cannot be sure that the update value will be the first or the last record from your FROM clause as it is not defined.

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

Sidebar

Related Questions

Let me frame it this way.. Say I have an application server running on
Let's say I have table with column 'URL' whrere I store urls like this
Let's say I have this MySQL table: OK.. see the type field? Type 0
Let's say i have this block of code, <div id=id1> This is some text
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I can call a method like this: core::get() . What is the
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have an facebook application running using the JS SDK. First user
Let's say there is a graph and some set of functions like: create-node ::

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.