Update one table from another table in the same SQL Server

Posted on 2009-02-17
Last Modified: 2012-06-27
I have two Tables with the same name, in two differrent database on the same MS-SQL Server 2000, and I wanted to update one colomn in one table from the other database.

X1   Y1   Z1

X2   Y2   Z2

So, the Query should looks like
Update Z2 from Z1.

I hope I make it clear for you guys, please let me know.
Question by:Naser Gabaj
    LVL 92

    Accepted Solution

    UPDATE Database1.dbo.SomeTable
    SET SomeColumn = t2.SomeColumn
    FROM Database1.dbo.SomeTable t1 INNER JOIN
          Database2.dbo.SomeTable t2 ON t1.ID = t2.ID
    LVL 60

    Assisted Solution

    update t1
    set z2 = t2.z1
    from db1..t1
    join db2..t2 on t1.commonfield = t2.commonfield
    LVL 15

    Author Closing Comment

    by:Naser Gabaj
    Hi All,

    Thank you Guys for your instant answer, and I apologize for being late to reply to you.

    Kind Regards,


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    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

    19 Experts available now in Live!

    Get 1:1 Help Now