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
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Update data from a table to the other

Author  Topic 

minhle
Starting Member

4 Posts

Posted - 2011-11-21 : 05:09:33
I have two table:
Table A (ID, field1, field2)
Table B (ID, field2, field3)

I would link to replace value of field 2 of B into field 2 of A where A.ID = B.ID
I write query in SQL 2005 as belows

Update (select A.*, B.* from A, B where (A.ID=B.ID)) SET A.field2 = B.field2
But my query is not working.

Any one can have me?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-21 : 05:13:54
it should be

Update a
set a.field2=b.field2
from TableA a
inner join TableB b
on b.ID = a.ID



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -