|
create table A (code int, name char (1), status char (2))
insert A select 1, 'a', '01'
union all select 2, 'b', '02'
union all select 3, 'c', '03'
create table B (code int, status char (2))
insert B select 1, '01'
union all select 2, '01'
union all select 3, '01'
update A set A.status = B.status
from B
where A.code = B.code
select * from A
--result
code name status
----------- ---- ------
1 a 01
2 b 01
3 c 01
(3 row (s) affected) |
|