How to update records in TableA with records in TableB

Posted on 2005-05-14
Last Modified: 2010-03-19
How do I update records in TableA with records in TableB.  The table structure is exactly the same and I have a common field for a where clause or something.
Question by:Brian Coughter
    1 Comment
    LVL 13

    Accepted Solution

    This will update the orders table in the Northwind database:

    UPDATE Orders
    SET Orders.ShipCountry = Customers.Country
    FROM Orders
    LEFT JOIN Customers ON
    Orders.CustomerID = Customers.CustomerID
    WHERE Customers.Country = 'Mexico'

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    I recently came across an interesting Question In EE ( and was puzzled about how to achieve that using SSIS out of the box tasks, which was i…
    I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now