Updating Multiple columns of a Table by selecting Multiple columns from another Table

Posted on 2011-05-04
Last Modified: 2012-05-11
I have a table T1 which has the following columns A, B, C and D.
I have another table T2 having these columns: P, Q, R and S.

Now I want to update the table T1, like this:
I will select the columns from the table T2, and update the columns of T1.

I mean, Column A of T1 should be updated by (Select P from T2),

Column B of T1 should be updated by (Select Q from T2)..

And so on..
Can anyone please help me, in finding the solution for the same?
Thanks in advance.
Question by:andrishelp
    1 Comment
    LVL 32

    Accepted Solution

    update T1
    set A = T2.P,
        B = T2.Q,
        C = T2.R,
        D = T2.S
    from T2 
    inner join T1 on T2.PrimaryKey = T1.PrimaryKey

    Open in new window


    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
    Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    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

    24 Experts available now in Live!

    Get 1:1 Help Now