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
 Forum Newbie Group: General Forum Members Last Login: Monday, April 14, 2014 12:56 AM Points: 8, Visits: 43
 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
 SSCertifiable Group: General Forum Members Last Login: Thursday, April 17, 2014 9:33 AM Points: 6,754, Visits: 12,854
Post #1525518
 Posted Friday, January 03, 2014 2:56 PM
 SSC-Addicted Group: General Forum Members Last Login: Friday, April 18, 2014 6:19 AM Points: 437, Visits: 282
 UPDATE x SET x.b = y.d FROM TABLE1 x JOIN table2 y ON x.a = y.c
Post #1527736
 Posted Friday, January 03, 2014 8:42 PM
 SSC-Dedicated Group: General Forum Members Last Login: Yesterday @ 10:06 PM Points: 35,978, Visits: 30,269
 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." "Change is inevitable. Change for the better is not." -- 04 August 2013(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013Helpful Links:How to post code problemsHow to post performance problems
Post #1527772

 Permissions