Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Updating a column in one table from another table

Author  Topic 

gautham.gn
Starting Member

19 Posts

Posted - 2013-12-23 : 07:57:18
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,,

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-12-23 : 08:06:46
[code]UPDATE tX
SET tX.b = tY.d
FROM dbo.X AS tX
INNER JOIN dbo.Y AS tY ON tY.c = tX.a;[/code]



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
   

- Advertisement -