Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Updating a column in one table from another table Rate Topic Display Mode Topic Options
Author
 Message
 Posted Monday, December 23, 2013 6:03 AM
 Grasshopper Group: General Forum Members Last Login: Tuesday, February 3, 2015 5:28 AM Points: 16, Visits: 86
 We have two tables with names X and Y.X has a,b columns. And Y has c,d columns.I want to update b column in X table with the values from d column in Y table on condition X.a=Y.c.Can u help me with this query??Thanks,,
Post #1525505
 Posted Monday, December 23, 2013 6:28 AM
 SSCrazy Eights Group: General Forum Members Last Login: Yesterday @ 9:41 AM Points: 8,605, Visits: 18,775
Post #1525518
 Posted Friday, January 3, 2014 2:56 PM
 SSChasing Mays Group: General Forum Members Last Login: Thursday, November 10, 2016 2:25 PM Points: 649, Visits: 613
 UPDATE x SET x.b = y.d FROM TABLE1 x JOIN table2 y ON x.a = y.c
Post #1527736
 Posted Friday, January 3, 2014 8:42 PM
 SSC-Forever Group: General Forum Members Last Login: Today @ 10:52 PM Points: 42,083, Visits: 39,479
 Just to be clear, Chris was trying to get the OP to teach themselves how to answer such simple questions on their own instead of making them permanently dependent on the kindness of others on the web. Books Online is a very good tool for learning such basics and more. I'm amazed at how many people that are using SQL Server that don't even know what Books Online is.@gautham.gn,Two questions for you now that you have the coded answer to your question... 1) Do you understand all of the parts of that code and why it works and 2) do you know what Books Online actually is? --Jeff Moden"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column." Helpful Links:How to post code problemsHow to post performance problems
Post #1527772

 Permissions