Wednesday, 23 February 2011

SQL Update with two tables

SQL query to update fields matching a field from an other table:


UPDATE A
SET A.NAME = B.NAME
FROM TableNameA A, TableNameB B
WHERE A.ID = B.ID


or better

UPDATE A
SET A.NAME = B.NAME
FROM TableNameA A
INNER JOIN TableName B ON
A.ID = B.ID

No comments:

Post a Comment